[Buildbot-commits] buildbot/buildbot/process step.py,1.63,1.64 base.py,1.49,1.50

Brian Warner warner at users.sourceforge.net
Tue May 3 20:02:06 UTC 2005


Update of /cvsroot/buildbot/buildbot/buildbot/process
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3245/buildbot/process

Modified Files:
	step.py base.py 
Log Message:
Revision: arch at buildbot.sf.net--2004/buildbot--dev--0--patch-117
Creator:  Brian Warner <warner at monolith.lothar.com>

support Baz, revisions for tla+baz, make error steps terminate build

	* buildbot/process/base.py (Build.startBuild): fix a bug that
	caused an exception when the build terminated in the very first
	step.
	(Build.stepDone): let steps return a status of EXCEPTION. This
	terminates the build right away, and sets the build's overall
	status to EXCEPTION too.
	* buildbot/process/step.py (BuildStep.failed): return a status of
	EXCEPTION when that is what has happened.

	* buildbot/process/step.py (Arch.computeSourceRevision): finally
	implement this, allowing Arch-based projects to get precise
	checkouts instead of always using the latest code
	(Bazaar): create variant of Arch to let folks use baz instead of
	tla. Requires a new buildslave too.
	* buildbot/slave/commands.py (Arch): add 'revision' argument
	(Bazaar): create variant of Arch that uses baz instead of tla.
	Remove the code that extracts the archive name from the
	register-archive output, since baz doesn't provide it, and require
	the user provide both the archive name and its location.
	* buildbot/test/test_vc.py (VC.testBazaar): added tests


Index: base.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/process/base.py,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- base.py	24 Apr 2005 21:56:41 -0000	1.49
+++ base.py	3 May 2005 20:02:03 -0000	1.50
@@ -11,7 +11,8 @@
 
 from buildbot import interfaces
 from buildbot.util import now
-from buildbot.status.builder import SUCCESS, WARNINGS, FAILURE, Results
+from buildbot.status.builder import SUCCESS, WARNINGS, FAILURE, EXCEPTION
+from buildbot.status.builder import Results
 from buildbot.status.progress import BuildProgress
 
 class Build:
@@ -270,7 +271,7 @@
         self.build_status = build_status
         self.remote = remote
         self.remote.notifyOnDisconnect(self.lostRemote)
-        self.deferred = defer.Deferred()
+        d = self.deferred = defer.Deferred()
 
         try:
             self.setupBuild(expectations) # create .steps
@@ -287,14 +288,13 @@
                                                       color="purple")
             self.finished = True
             self.results = FAILURE
-            d = self.deferred
             self.deferred = None
             d.callback(self)
             return d
 
         self.build_status.buildStarted(self)
         self.startNextStep()
-        return self.deferred
+        return d
 
     def setupBuild(self, expectations):
         # create the actual BuildSteps. If there are any name collisions, we
@@ -418,6 +418,9 @@
                     self.result = WARNINGS
             if step.flunkOnWarnings:
                 self.result = FAILURE
+        elif result == EXCEPTION:
+            self.result = EXCEPTION
+            terminate = True
         return terminate
 
     def lostRemote(self, remote):

Index: step.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/process/step.py,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- step.py	24 Apr 2005 21:56:41 -0000	1.63
+++ step.py	3 May 2005 20:02:01 -0000	1.64
@@ -566,7 +566,7 @@
             # think that it is still running), but the build overall will now
             # finish
         log.msg("BuildStep.failed now firing callback")
-        self.deferred.callback(FAILURE)
+        self.deferred.callback(EXCEPTION)
 
     # utility methods that BuildSteps may find useful
 
@@ -1191,14 +1191,11 @@
         ShellCommand.start(self)
 
 class Arch(Source):
-    """Check out a source tree from an Arch repository at 'url'. 'version'
-    specifies which version number (development line) will be used for the
-    checkout: this is mostly equivalent to a branch name.
-    
-    This step will first register the archive, which requires a per-user
-    'archive name' to correspond to the URL from which the sources can be
-    fetched. The archive's default name will be used for this unless you
-    override it by setting the 'archive' parameter.
+    """Check out a source tree from an Arch repository named 'archive'
+    available at 'url'. 'version' specifies which version number (development
+    line) will be used for the checkout: this is mostly equivalent to a
+    branch name. This version uses the 'tla' tool to do the checkout, to use
+    'baz' see L{Bazaar} instead.
     """
 
     name = "arch"
@@ -1214,12 +1211,9 @@
         @param version: the category--branch--version to check out
 
         @type  archive: string
-        @param archive: an optional archive name, to override the one
-                        provided by the repository. You might want to do this
-                        if, for some reason, you are hosting the archive on
-                        the same machine (and in the same account) as the
-                        build slave, and you don't want to confuse local
-                        access with remote access.
+        @param archive: The archive name. If provided, it must match the one
+                        that comes from the repository. If not, the
+                        repository's default will be used.
         """
         Source.__init__(self, **kwargs)
         self.args.update({'url': url,
@@ -1227,12 +1221,94 @@
                           'archive': archive,
                           })
 
-    def startVC(self):
+    def checkSlaveVersion(self):
         slavever = self.slaveVersion("arch")
         assert slavever, "slave is too old, does not know about arch"
+        # slave 1.28 and later understand 'revision'
+        oldslave = False
+        try:
+            if slavever.startswith("1.") and int(slavever[2:]) < 28:
+                oldslave = True
+        except ValueError:
+            pass
+        if oldslave:
+            if not self.alwaysUseLatest:
+                log.msg("warning, slave is too old to use a revision")
+
+    def startVC(self):
+        self.checkSlaveVersion()
         self.cmd = LoggedRemoteCommand("arch", self.args)
         ShellCommand.start(self)
 
+    def computeSourceRevision(self, changes):
+        # in Arch, fully-qualified revision numbers look like:
+        #  arch at buildbot.sourceforge.net--2004/buildbot--dev--0--patch-104
+        # For any given builder, all of this is fixed except the patch-104.
+        # The Change might have any part of the fully-qualified string, so we
+        # just look for the last part. We return the "patch-NN" string.
+        if not changes:
+            return None
+        lastChange = None
+        for c in changes:
+            if not c.revision:
+                continue
+            if c.revision.endswith("--base-0"):
+                rev = 0
+            else:
+                i = c.revision.rindex("patch")
+                rev = int(c.revision[i+len("patch-"):])
+            lastChange = max(lastChange, rev)
+        if lastChange is None:
+            return None
+        if lastChange == 0:
+            return "base-0"
+        return "patch-%d" % lastChange
+
+class Bazaar(Arch):
+    """Bazaar is an alternative client for Arch repositories. baz is mostly
+    compatible with tla, but archive registration is slightly different."""
+
+
+    def __init__(self, url, version, archive, **kwargs):
+        """
+        @type  url: string
+        @param url: the Arch coordinates of the repository. This is
+                    typically an http:// URL, but could also be the absolute
+                    pathname of a local directory instead.
+
+        @type  version: string
+        @param version: the category--branch--version to check out
+
+        @type  archive: string
+        @param archive: The archive name (required). This must always match
+                        the one that comes from the repository, otherwise the
+                        buildslave will attempt to get sources from the wrong
+                        archive.
+        """
+        Source.__init__(self, **kwargs)
+        self.args.update({'url': url,
+                          'version': version,
+                          'archive': archive,
+                          })
+
+    def checkSlaveVersion(self):
+        slavever = self.slaveVersion("arch")
+        assert slavever, "slave is too old, does not know about arch"
+        # slave 1.28 and later understand baz
+        oldslave = False
+        try:
+            if slavever.startswith("1.") and int(slavever[2:]) < 28:
+                oldslave = True
+        except ValueError:
+            pass
+        assert not oldslave, "slave is too old, does not know about baz"
+
+    def startVC(self):
+        self.checkSlaveVersion()
+        self.cmd = LoggedRemoteCommand("bazaar", self.args)
+        ShellCommand.start(self)
+
+
 class todo_P4(Source):
     name = "p4"
 





More information about the Commits mailing list