[Buildbot-commits] buildbot/buildbot/scripts runner.py,1.33,1.34 tryclient.py,1.4,1.5

Brian Warner warner at users.sourceforge.net
Mon Aug 15 18:05:08 UTC 2005


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

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

rewrite test_vc, make 'try' work for Darcs

	* buildbot/scripts/tryclient.py (getSourceStamp): extract branches
	where we can (Arch), add a branch= argument to set the branch used
	when we can't
	(BazExtractor): extract the branch too
	(TlaExtractor): same
	* buildbot/scripts/runner.py (TryOptions): add --branch
	* docs/buildbot.texinfo (try): document --branch/try_branch

	* buildbot/slave/commands.py (Darcs): implement get-revision for
	Darcs, so that 'try' will work. This requires the tempfile module
	from python-2.3 .

	* buildbot/test/test_vc.py: rewrite tests, getting better coverage
	of revisions, branches, and 'try' in the process.


Index: runner.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/scripts/runner.py,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- runner.py	11 Aug 2005 20:21:30 -0000	1.33
+++ runner.py	15 Aug 2005 18:05:05 -0000	1.34
@@ -577,6 +577,9 @@
         
         ["vc", None, None,
          "The VC system in use, one of: cvs,svn,tla,baz,darcs"],
+        ["branch", None, None,
+         "The branch in use, for VC systems that can't figure it out"
+         " themselves"],
 
         ["builder", "b", None,
          "Run the trial build on this Builder. Can be used multiple times."],

Index: tryclient.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/scripts/tryclient.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- tryclient.py	11 Aug 2005 20:21:30 -0000	1.4
+++ tryclient.py	15 Aug 2005 18:05:05 -0000	1.5
@@ -10,9 +10,11 @@
 from buildbot.scripts import runner
 
 class SourceStampExtractor:
-    branch = None
-    def __init__(self, treetop):
+
+    def __init__(self, treetop, branch):
         self.treetop = treetop
+        self.branch = branch
+
     def do(self, cmd):
         return utils.getProcessOutput(cmd[0], cmd[1:], env=os.environ,
                                       path=self.treetop)
@@ -56,8 +58,7 @@
         for line in res.split("\n"):
             m = re.search(r'^Status against revision:\s+(\d+)', line)
             if m:
-                num = m.group(1)
-                self.baserev = int(num)
+                self.baserev = int(m.group(1))
                 return
         raise IndexError("Could not find 'Status against revision' in "
                          "SVN output: %s" % res)
@@ -72,7 +73,11 @@
         d.addCallback(self.parseStatus)
         return d
     def parseStatus(self, res):
-        self.baserev = res.strip()
+        tid = res.strip()
+        slash = tid.index("/")
+        dd = tid.rindex("--")
+        self.branch = tid[slash+1:dd]
+        self.baserev = tid[dd+2:]
     def getPatch(self, res):
         d = self.do(["baz", "diff"])
         d.addCallback(self.readPatch, 1)
@@ -80,12 +85,18 @@
 
 class TlaExtractor(SourceStampExtractor):
     def getBaseRevision(self):
+        # 'tla logs --full' gives us ARCHIVE/BRANCH--REVISION
+        # 'tla logs' gives us REVISION
         d = self.do(["tla", "logs", "--full", "--reverse"])
         d.addCallback(self.parseStatus)
         return d
     def parseStatus(self, res):
-        lines = res.split("\n")
-        self.baserev = lines[0].strip()
+        tid = res.split("\n")[0].strip()
+        slash = tid.index("/")
+        dd = tid.rindex("--")
+        self.branch = tid[slash+1:dd]
+        self.baserev = tid[dd+2:]
+
     def getPatch(self, res):
         d = self.do(["tla", "changes", "--diffs"])
         d.addCallback(self.readPatch, 1)
@@ -104,17 +115,19 @@
         d.addCallback(self.readPatch, self.patchlevel)
         return d
 
-def getSourceStamp(vctype, treetop):
+def getSourceStamp(vctype, treetop, branch=None):
     if vctype == "cvs":
+        # use time.strftime("%Y-%m-%d %H:%M:%S %z", time.gmtime()),
+        # use in a cvs diff -D command?
         raise NotImplementedError("CVSExtractor not yet implemented")
     elif vctype == "svn":
-        e = SVNExtractor(treetop)
+        e = SVNExtractor(treetop, branch)
     elif vctype == "baz":
-        e = BazExtractor(treetop)
+        e = BazExtractor(treetop, branch)
     elif vctype == "tla":
-        e = TlaExtractor(treetop)
+        e = TlaExtractor(treetop, branch)
     elif vctype == "darcs":
-        e = DarcsExtractor(treetop)
+        e = DarcsExtractor(treetop, branch)
     else:
         raise KeyError("unknown vctype '%s'" % vctype)
     return e.get()
@@ -162,6 +175,7 @@
         self.config = config
         self.opts = runner.loadOptions()
         self.connect = self.getopt('connect', 'try_connect')
+        assert self.connect, "you must specify a connect style: ssh or pb"
         self.builderNames = self.getopt('builders', 'try_builders')
         assert self.builderNames, "no builders! use --builder or " \
                "try_builders=[names..] in .buildbot/options"
@@ -172,7 +186,6 @@
             value = self.opts.get(options_name)
         if value is None or value == []:
             value = default
-        assert value is not None
         return value
 
     def createJob(self):
@@ -184,6 +197,7 @@
 
         # common options
         vc = self.getopt("vc", "try_vc")
+        branch = self.getopt("branch", "try_branch")
 
         if vc in ("cvs", "svn"):
             # we need to find the tree-top
@@ -195,7 +209,7 @@
                 treedir = getTopdir(topfile)
         else:
             treedir = os.getcwd()
-        d = getSourceStamp(vc, treedir)
+        d = getSourceStamp(vc, treedir, branch)
         d.addCallback(self._createJob_1)
         return d
     def _createJob_1(self, ss):





More information about the Commits mailing list