[Buildbot-commits] buildbot/buildbot/slave commands.py,1.66,1.67

Brian Warner warner at users.sourceforge.net
Mon Sep 25 07:46:58 UTC 2006


Update of /cvsroot/buildbot/buildbot/buildbot/slave
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv17754/buildbot/slave

Modified Files:
	commands.py 
Log Message:
[project @ initial support for Monotone, by Nathaniel Smith]

Original author: warner at lothar.com
Date: 2006-09-25 07:45:16

Index: commands.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/slave/commands.py,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -d -r1.66 -r1.67
--- commands.py	15 Sep 2006 14:49:46 -0000	1.66
+++ commands.py	25 Sep 2006 07:46:56 -0000	1.67
@@ -14,7 +14,7 @@
 # this used to be a CVS $-style "Revision" auto-updated keyword, but since I
 # moved to Darcs as the primary repository, this is updated manually each
 # time this file is changed. The last cvs_ver that was here was 1.51 .
-command_version = "2.1"
+command_version = "2.2"
 
 # version history:
 #  >=1.17: commands are interruptable
@@ -32,6 +32,7 @@
 #          ShellCommand accepts new arguments (logfiles=, initialStdin=,
 #          keepStdinOpen=) and no longer accepts stdin=)
 #          (release 0.7.4)
+#  >= 2.2: added monotone, uploadFile, and downloadFile
 
 class CommandInterrupted(Exception):
     pass
@@ -1530,6 +1531,112 @@
 
 registerSlaveCommand("darcs", Darcs, command_version)
 
+class Monotone(SourceBase):
+    """Monotone-specific VC operation.  In addition to the arguments handled
+    by SourceBase, this command reads the following keys:
+
+    ['server_addr'] (required): the address of the server to pull from
+    ['branch'] (required): the branch the revision is on
+    ['db_path'] (required): the local database path to use
+    ['revision'] (required): the revision to check out
+    ['monotone']: (required): path to monotone executable
+    """
+
+    header = "monotone operation"
+
+    def setup(self, args):
+        SourceBase.setup(self, args)
+        self.server_addr = args["server_addr"]
+        self.branch = args["branch"]
+        self.db_path = args["db_path"]
+        self.revision = args["revision"]
+        self.monotone = args["monotone"]
+        self._made_fulls = False
+        self._pull_timeout = args["timeout"]
+
+    def _makefulls(self):
+        if not self._made_fulls:
+            basedir = self.builder.basedir
+            self.full_db_path = os.path.join(basedir, self.db_path)
+            self.full_srcdir = os.path.join(basedir, self.srcdir)
+            self._made_fulls = True
+
+    def sourcedirIsUpdateable(self):
+        self._makefulls()
+        if os.path.exists(os.path.join(self.full_srcdir,
+                                       ".buildbot_patched")):
+            return False
+        return (os.path.isfile(self.full_db_path)
+                and os.path.isdir(os.path.join(self.full_srcdir, "MT")))
+
+    def doVCUpdate(self):
+        return self._withFreshDb(self._doUpdate)
+
+    def _doUpdate(self):
+        # update: possible for mode in ('copy', 'update')
+        command = [self.monotone, "update",
+                   "-r", self.revision,
+                   "-b", self.branch]
+        c = ShellCommand(self.builder, command, self.full_srcdir,
+                         sendRC=False, timeout=self.timeout)
+        self.command = c
+        return c.start()
+
+    def doVCFull(self):
+        return self._withFreshDb(self._doFull)
+
+    def _doFull(self):
+        command = [self.monotone, "--db=" + self.full_db_path,
+                   "checkout",
+                   "-r", self.revision,
+                   "-b", self.branch,
+                   self.full_srcdir]
+        c = ShellCommand(self.builder, command, self.builder.basedir,
+                         sendRC=False, timeout=self.timeout)
+        self.command = c
+        return c.start()
+
+    def _withFreshDb(self, callback):
+        self._makefulls()
+        # first ensure the db exists and is usable
+        if os.path.isfile(self.full_db_path):
+            # already exists, so run 'db migrate' in case monotone has been
+            # upgraded under us
+            command = [self.monotone, "db", "migrate",
+                       "--db=" + self.full_db_path]
+        else:
+            # We'll be doing an initial pull, so up the timeout to 3 hours to
+            # make sure it will have time to complete.
+            self._pull_timeout = max(self._pull_timeout, 3 * 60 * 60)
+            self.sendStatus({"header": "creating database %s\n"
+                                       % (self.full_db_path,)})
+            command = [self.monotone, "db", "init",
+                       "--db=" + self.full_db_path]
+        c = ShellCommand(self.builder, command, self.builder.basedir,
+                         sendRC=False, timeout=self.timeout)
+        self.command = c
+        d = c.start()
+        d.addCallback(self._abandonOnFailure)
+        d.addCallback(self._didDbInit)
+        d.addCallback(self._didPull, callback)
+        return d
+
+    def _didDbInit(self, res):
+        command = [self.monotone, "--db=" + self.full_db_path,
+                   "pull", "--ticker=dot", self.server_addr, self.branch]
+        c = ShellCommand(self.builder, command, self.builder.basedir,
+                         sendRC=False, timeout=self._pull_timeout)
+        self.sendStatus({"header": "pulling %s from %s\n"
+                                   % (self.branch, self.server_addr)})
+        self.command = c
+        return c.start()
+
+    def _didPull(self, res, callback):
+        return callback()
+
+registerSlaveCommand("monotone", Monotone, command_version)
+
+
 class Git(SourceBase):
     """Git specific VC operation. In addition to the arguments
     handled by SourceBase, this command reads the following keys:





More information about the Commits mailing list