4 Script for BuildBot to monitor a remote Subversion repository.
5 Copyright (C) 2006 John Pye
7 # This script is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License, or (at your option) any later version.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 import xml
.dom
.minidom
28 # change these settings to match your project
29 svnurl
= "https://pse.cheme.cmu.edu/svn/ascend/code/trunk"
30 statefilename
= "~/changemonitor/config.ini"
31 buildmaster
= "buildbot.example.org:9989" # connects to a PBChangeSource
33 xml1
= commands
.getoutput(
34 "svn log --non-interactive --verbose --xml --limit=1 " + svnurl
)
35 #print "XML\n-----------\n"+xml1+"\n\n"
38 doc
= xml
.dom
.minidom
.parseString(xml1
)
39 el
= doc
.getElementsByTagName("logentry")[0]
40 revision
= el
.getAttribute("revision")
41 author
= "".join([t
.data
for t
in el
.getElementsByTagName(
42 "author")[0].childNodes
])
43 comments
= "".join([t
.data
for t
in el
.getElementsByTagName(
44 "msg")[0].childNodes
])
46 pathlist
= el
.getElementsByTagName("paths")[0]
48 for p
in pathlist
.getElementsByTagName("path"):
49 paths
.append("".join([t
.data
for t
in p
.childNodes
]))
52 except xml
.parsers
.expat
.ExpatError
, e
:
53 print "FAILED TO PARSE 'svn log' XML:"
56 print "RECEIVED TEXT:"
62 fname
= os
.path
.expanduser(fname
)
63 ini
= ConfigParser
.SafeConfigParser()
68 print "Creating changemonitor config.ini:", fname
69 ini
.add_section("CurrentRevision")
70 ini
.set("CurrentRevision", -1)
73 lastrevision
= ini
.get("CurrentRevision", "changeset")
74 except ConfigParser
.NoOptionError
:
75 print "NO OPTION FOUND"
77 except ConfigParser
.NoSectionError
:
78 print "NO SECTION FOUND"
81 if lastrevision
!= revision
:
83 #comments = codecs.encodings.unicode_escape.encode(comments)
84 cmd
= "buildbot sendchange --master="+buildmaster
+" --branch=trunk \
85 --revision=\""+revision
+"\" --username=\""+author
+"\" --comments=\""+\
86 comments
+"\" "+" ".join(paths
)
89 res
= commands
.getoutput(cmd
)
91 print "SUBMITTING NEW REVISION", revision
92 if not ini
.has_section("CurrentRevision"):
93 ini
.add_section("CurrentRevision")
95 ini
.set("CurrentRevision", "changeset", revision
)
98 #print "WROTE CHANGES TO",fname
100 print "FAILED TO RECORD INI FILE"