testcase for #35, dependent schedulers lost on reconfig; reconfigure without changes...
[buildbot.git] / contrib / hg_buildbot.py
blob3be49f6eb7585367ed1be4c9e64b2a494e15f82d
1 #! /usr/bin/python
3 # This is a script which delivers Change events from Mercurial to the
4 # buildmaster each time a changeset is pushed into a repository. Add it to
5 # the 'incoming' commit hook on your canonical "central" repository, by
6 # putting something like the following in the .hg/hgrc file of that
7 # repository:
9 # [hooks]
10 # incoming.buildbot = /PATH/TO/hg_buildbot.py BUILDMASTER:PORT
12 # Note that both Buildbot and Mercurial must be installed on the repository
13 # machine.
15 import os
16 import sys
17 import commands
19 from StringIO import StringIO
20 from buildbot.scripts import runner
22 MASTER = sys.argv[1]
24 CHANGESET_ID = os.environ["HG_NODE"]
26 # TODO: consider doing 'import mercurial.hg' and extract this information
27 # using the native python
28 out = commands.getoutput(
29 "hg log -r %s --template '{author}\n{files}\n{desc}'" % CHANGESET_ID)
31 s = StringIO(out)
32 user = s.readline().strip()
33 # NOTE: this fail when filenames contain spaces. I cannot find a way to get
34 # hg to use some other filename separator.
35 files = s.readline().strip().split()
36 comments = "".join(s.readlines())
38 change = {
39 'master': MASTER,
40 # note: this is more likely to be a full email address, which would make
41 # the left-hand "Changes" column kind of wide. The buildmaster should
42 # probably be improved to display an abbreviation of the username.
43 'username': user,
44 'revision': CHANGESET_ID,
45 'comments': comments,
46 'files': files,
49 runner.sendchange(change, True)