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
15 import os
, sys
, commands
16 from StringIO
import StringIO
17 from buildbot
.scripts
import runner
21 CHANGESET_ID
= os
.environ
["HG_NODE"]
23 # TODO: consider doing 'import mercurial.hg' and extract this information
24 # using the native python
25 out
= commands
.getoutput("hg log -r %s --template '{author}\n{files}\n{desc}'" % CHANGESET_ID
)
28 user
= s
.readline().strip()
29 # NOTE: this fail when filenames contain spaces. I cannot find a way to get
30 # hg to use some other filename separator.
31 files
= s
.readline().strip().split()
32 comments
= "".join(s
.readlines())
36 # note: this is more likely to be a full email address, which would make
37 # the left-hand "Changes" column kind of wide. The buildmaster should
38 # probably be improved to display an abbreviation of the username.
40 'revision': CHANGESET_ID
,
45 runner
.sendchange(change
, True)