[Buildbot-commits] buildbot/buildbot/process step.py,1.71,1.72

Brian Warner warner at users.sourceforge.net
Sat Oct 22 23:22:12 UTC 2005


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

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

handle older slaves better (mostly multiple-branch support)

	* buildbot/test/test_runner.py (Options.testForceOptions): skip
	when running under older pythons (<2.3) in which the shlex module
	doesn't have a 'split' function.

	* buildbot/process/step.py (ShellCommand.start): make
	errorMessages= be a list of strings to stuff in the log before the
	command actually starts. This makes it easier to flag multiple
	warning messages, e.g. when the Source steps have to deal with an
	old buildslave.
	(CVS.startVC): handle slaves that don't handle multiple branches
	by switching into 'clobber' mode
	(SVN.startVC): same. Also reject branches without base_url
	(Darcs.startVC): same. Also reject revision= in older slaves
	(Arch.checkSlaveVersion): same (just the multiple-branches stuff)
	(Bazaar.startVC): same, and test for baz separately than for arch


Index: step.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/process/step.py,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- step.py	22 Oct 2005 22:41:58 -0000	1.71
+++ step.py	22 Oct 2005 23:22:10 -0000	1.72
@@ -743,7 +743,7 @@
             return ["'%s" % words[0], "%s'" % words[1]]
         return ["'%s" % words[0], "%s" % words[1], "...'"]
 
-    def start(self, errorMessage=None):
+    def start(self, errorMessages=[]):
         # merge in anything from Build.slaveEnvironment . Earlier steps
         # (perhaps ones which compile libraries or sub-projects that need to
         # be referenced by later steps) can add keys to
@@ -759,8 +759,8 @@
         self.step_status.setColor("yellow")
         self.step_status.setText(self.describe(False))
         loog = self.addLog("log")
-        if errorMessage:
-            loog.addHeader(errorMessage)
+        for em in errorMessages:
+            loog.addHeader(em)
         log.msg("ShellCommand.start using log", loog)
         log.msg(" for cmd", self.cmd)
         self.cmd.useLog(loog, True)
@@ -1200,8 +1200,22 @@
             # TODO: figure out why, see if it applies to -r BRANCH
             self.args['branch'] = None
 
-        # accomodate old slaves
+        # deal with old slaves
+        warnings = []
         slavever = self.slaveVersion("cvs", "old")
+        if not self.slaveVersionNewEnough("cvs", "1.39"):
+            # the slave doesn't know to avoid re-using the same sourcedir
+            # when the branch changes. We have no way of knowing which branch
+            # the last build used, so if we're using a non-default branch and
+            # either 'update' or 'copy' modes, it is safer to switch to
+            # 'clobber' mode.
+            if branch != None and self.args['mode'] in ("update", "copy"):
+                m = ("buildslave does not know about multiple branches, "
+                     "switching from mode=%s to mode=clobber to insure "
+                     "we don't build the wrong branch." % self.args['mode'])
+                warnings.append(m + "\n")
+                log.msg(m)
+                self.args['mode'] = "clobber"
         if slavever == "old":
             # 0.5.0
             if self.args['mode'] == "export":
@@ -1214,7 +1228,7 @@
             assert not self.args['patch'] # 0.5.0 slave can't do patch
 
         self.cmd = LoggedRemoteCommand("cvs", self.args)
-        ShellCommand.start(self)
+        ShellCommand.start(self, warnings)
 
 
 class SVN(Source):
@@ -1271,29 +1285,45 @@
     def startVC(self, branch, revision, patch):
 
         # accomodate old slaves
-        errorMessage = None
+        warnings = []
         slavever = self.slaveVersion("svn", "old")
+
         assert slavever, "slave does not have the 'svn' command"
+        if not self.slaveVersionNewEnough("svn", "1.39"):
+            # the slave doesn't know to avoid re-using the same sourcedir
+            # when the branch changes. We have no way of knowing which branch
+            # the last build used, so if we're using a non-default branch and
+            # either 'update' or 'copy' modes, it is safer to switch to
+            # 'clobber' mode.
+            if branch != None and self.args['mode'] in ("update", "copy"):
+                m = ("buildslave does not know about multiple branches, "
+                     "switching from mode=%s to mode=clobber to insure "
+                     "we don't build the wrong branch." % self.args['mode'])
+                warnings.append(m + "\n")
+                log.msg(m)
+                self.args['mode'] = "clobber"
+
         if slavever == "old":
             # 0.5.0 compatibility
             if self.args['mode'] in ("clobber", "copy"):
                 # TODO: use some shell commands to make up for the
                 # deficiency, by blowing away the old directory first (thus
                 # forcing a full checkout)
-                errorMessage = "WARNING: this slave can only do SVN updates"
-                errorMessage += ", not mode=%s\n" % self.args['mode']
+                warnings.append("WARNING: this slave can only do SVN updates"
+                                ", not mode=%s\n" % self.args['mode'])
                 log.msg("WARNING: this slave only does mode=update")
             assert self.args['mode'] != "export" # more serious
             self.args['directory'] = self.args['workdir']
             if revision is not None:
                 # 0.5.0 can only do HEAD
-                errorMessage = "WARNING: this slave can only update to HEAD"
-                errorMessage += ", not revision=%s\n" % revision
+                warnings.append("WARNING: this slave can only update to "
+                                "HEAD, not revision=%s\n" % revision)
                 log.msg("WARNING: this slave only does -rHEAD")
             revision = "HEAD" # interprets this key differently
             assert not patch # 0.5.0 slave can't do patch
 
         if self.svnurl:
+            assert not branch # we need base_url= to use branches
             self.args['svnurl'] = self.svnurl
         else:
             self.args['svnurl'] = self.base_url + branch
@@ -1301,7 +1331,7 @@
         self.args['patch'] = patch
 
         self.cmd = LoggedRemoteCommand("svn", self.args)
-        ShellCommand.start(self, errorMessage)
+        ShellCommand.start(self, warnings)
 
 
 class Darcs(Source):
@@ -1350,9 +1380,24 @@
     def startVC(self, branch, revision, patch):
         slavever = self.slaveVersion("darcs")
         assert slavever, "slave is too old, does not know about darcs"
+        if not self.slaveVersionNewEnough("darcs", "1.39"):
+            # 0.6.6 slaves can't handle args['revision']
+            assert not revision
+            # the slave doesn't know to avoid re-using the same sourcedir
+            # when the branch changes. We have no way of knowing which branch
+            # the last build used, so if we're using a non-default branch and
+            # either 'update' or 'copy' modes, it is safer to switch to
+            # 'clobber' mode.
+            if branch != None and self.args['mode'] in ("update", "copy"):
+                m = ("buildslave does not know about multiple branches, "
+                     "switching from mode=%s to mode=clobber to insure "
+                     "we don't build the wrong branch." % self.args['mode'])
+                warnings.append(m + "\m")
+                log.msg(m)
+                self.args['mode'] = "clobber"
 
-        # TODO: 0.6.6 slaves can't handle args['revision']
         if self.repourl:
+            assert not branch # we need base_url= to use branches
             self.args['repourl'] = self.repourl
         else:
             self.args['repourl'] = self.base_url + branch
@@ -1444,27 +1489,38 @@
             return "base-0"
         return "patch-%d" % lastChange
 
-    def checkSlaveVersion(self):
-        slavever = self.slaveVersion("arch")
+    def checkSlaveVersion(self, cmd):
+        warnings = []
+        slavever = self.slaveVersion(cmd)
         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.slaveVersionNewEnough(cmd, "1.28"):
             if not self.alwaysUseLatest:
-                log.msg("warning, slave is too old to use a revision")
+                log.msg("warning, buildslave is too old to use a revision")
+                warnings.append("buildslave is too old to use a revision")
+
+        if not self.slaveVersionNewEnough(cmd, "1.39"):
+            # the slave doesn't know to avoid re-using the same sourcedir
+            # when the branch changes. We have no way of knowing which branch
+            # the last build used, so if we're using a non-default branch and
+            # either 'update' or 'copy' modes, it is safer to switch to
+            # 'clobber' mode.
+            if branch != None and self.args['mode'] in ("update", "copy"):
+                m = ("buildslave does not know about multiple branches, "
+                     "switching from mode=%s to mode=clobber to insure "
+                     "we don't build the wrong branch." % self.args['mode'])
+                warnings.append(m + "\n")
+                log.msg(m)
+                self.args['mode'] = "clobber"
+        return warnings
 
     def startVC(self, branch, revision, patch):
         self.args['version'] = branch
         self.args['revision'] = revision
         self.args['patch'] = patch
-        self.checkSlaveVersion()
+        warnings = self.checkSlaveVersion("arch")
         self.cmd = LoggedRemoteCommand("arch", self.args)
-        ShellCommand.start(self)
+        ShellCommand.start(self, warnings)
 
 
 class Bazaar(Arch):
@@ -1495,25 +1551,13 @@
                           '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, branch, revision, patch):
         self.args['version'] = branch
         self.args['revision'] = revision
         self.args['patch'] = patch
-        self.checkSlaveVersion()
+        warnings = self.checkSlaveVersion("bazaar")
         self.cmd = LoggedRemoteCommand("bazaar", self.args)
-        ShellCommand.start(self)
+        ShellCommand.start(self, warnings)
 
 
 class todo_P4(Source):





More information about the Commits mailing list