[Buildbot-devel] Correct support for monotone

Markus Schiltknecht markus at bluegap.ch
Mon Jul 9 13:22:15 UTC 2007


Hi,

uppon request, I've compiled a patch from my hackery on buildbot, some 
time ago. This is very much an 'it works for me' thing, so please 
somebody with more knowledge of the buildbot internals: have a look at 
it before applying anything...

Regards

Markus

-------------- next part --------------
Index: buildbot/changes/monotone.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/changes/monotone.py,v
retrieving revision 1.2
diff -u -r1.2 monotone.py
--- buildbot/changes/monotone.py	23 Jan 2007 21:04:40 -0000	1.2
+++ buildbot/changes/monotone.py	9 Jul 2007 12:56:41 -0000
@@ -3,6 +3,7 @@
 import os
 from cStringIO import StringIO
 
+from zope.interface import implements
 from twisted.python import log
 from twisted.application import service
 from twisted.internet import defer, protocol, error, reactor
@@ -11,6 +12,7 @@
 from buildbot import util
 from buildbot.interfaces import IChangeSource
 from buildbot.changes.changes import Change
+from buildbot.changes import base
 
 class _MTProtocol(protocol.ProcessProtocol):
 
@@ -73,7 +75,7 @@
         return self._run_monotone(["pull", server, pattern])
 
     def get_revision(self, rid):
-        return self._run_monotone(["cat", "revision", rid])
+        return self._run_monotone(["automate", "get_revision", rid])
 
     def get_heads(self, branch, rcfile=""):
         cmd = ["automate", "heads", branch]
@@ -104,10 +106,10 @@
             depth_arg = ["--last=%i" % (depth,)]
         else:
             depth_arg = []
-        return self._run_monotone(["log", "-r", rev] + depth_arg)
+        return self._run_monotone(["log", "--no-graph", "--from", rev, "--last", "20"] + depth_arg)
 
 
-class MonotoneSource(service.Service, util.ComparableMixin):
+class MonotoneSource(base.ChangeSource):
     """This source will poll a monotone server for changes and submit them to
     the change master.
 
@@ -123,7 +125,8 @@
     @param monotone_exec: path to monotone executable, defaults to "monotone"
     """
 
-    __implements__ = IChangeSource, service.Service.__implements__
+    implements(IChangeSource)
+
     compare_attrs = ["server_addr", "trusted_keys", "db_path",
                      "pollinterval", "branch", "monotone_exec"]
 
Index: buildbot/slave/commands.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/slave/commands.py,v
retrieving revision 1.83
diff -u -r1.83 commands.py
--- buildbot/slave/commands.py	4 Jul 2007 05:52:04 -0000	1.83
+++ buildbot/slave/commands.py	9 Jul 2007 12:56:41 -0000
@@ -1648,10 +1648,11 @@
 
     def _doUpdate(self):
         # update: possible for mode in ('copy', 'update')
+        revision = self.revision or 'h:'
         command = [self.monotone, "update",
-                   "-r", self.revision,
+                   "-r", revision,
                    "-b", self.branch]
-        c = ShellCommand(self.builder, command, self.full_srcdir,
+        c = ShellCommand(self.builder, command, self.builder.basedir,
                          sendRC=False, timeout=self.timeout)
         self.command = c
         return c.start()
@@ -1660,13 +1661,15 @@
         return self._withFreshDb(self._doFull)
 
     def _doFull(self):
+        revision = self.revision or 'h:'
         command = [self.monotone, "--db=" + self.full_db_path,
                    "checkout",
-                   "-r", self.revision,
+                   "-r", revision,
                    "-b", self.branch,
                    self.full_srcdir]
         c = ShellCommand(self.builder, command, self.builder.basedir,
-                         sendRC=False, timeout=self.timeout)
+                         sendRC=False, timeout=self.timeout,
+                         keepStdout=True)
         self.command = c
         return c.start()
 
Index: buildbot/steps/source.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/steps/source.py,v
retrieving revision 1.7
diff -u -r1.7 source.py
--- buildbot/steps/source.py	3 Jul 2007 19:17:49 -0000	1.7
+++ buildbot/steps/source.py	9 Jul 2007 12:56:41 -0000
@@ -1026,8 +1026,7 @@
     name = "monotone"
 
     def __init__(self, server_addr, branch, db_path="monotone.db",
-                 monotone="monotone",
-                 **kwargs):
+                 monotone="mtn", **kwargs):
         Source.__init__(self, **kwargs)
         self.addFactoryArguments(server_addr=server_addr,
                                  branch=branch,
@@ -1044,9 +1043,11 @@
             return None
         return changes[-1].revision
 
-    def startVC(self):
+    def startVC(self, branch, revision, patch):
         slavever = self.slaveVersion("monotone")
         assert slavever, "slave is too old, does not know about monotone"
+        self.args['revision'] = revision
+        self.args['patch'] = patch
         cmd = LoggedRemoteCommand("monotone", self.args)
         self.startCommand(cmd)
 


More information about the devel mailing list