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
10 # incoming.buildbot = /PATH/TO/hg_buildbot.py BUILDMASTER:PORT
12 # Note that both Buildbot and Mercurial must be installed on the repository
19 from StringIO
import StringIO
20 from buildbot
.scripts
import runner
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
)
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())
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.
44 'revision': CHANGESET_ID
,
49 runner
.sendchange(change
, True)