[Buildbot-commits] buildbot/buildbot interfaces.py, 1.53, 1.54 sourcestamp.py, 1.4, 1.5

Brian Warner warner at users.sourceforge.net
Wed Aug 1 20:31:45 UTC 2007


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

Modified Files:
	interfaces.py sourcestamp.py 
Log Message:
[project @ pass around SourceStamp instances rather than tuples. Closes #70.]

Original author: warner at lothar.com
Date: 2007-07-31 06:25:40+00:00

Index: interfaces.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/interfaces.py,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- interfaces.py	17 Apr 2007 06:38:50 -0000	1.53
+++ interfaces.py	1 Aug 2007 20:31:43 -0000	1.54
@@ -73,7 +73,37 @@
         Scheduler might feed."""
 
 class ISourceStamp(Interface):
-    pass
+    """
+    @cvar branch: branch from which source was drawn
+    @type branch: string or None
+
+    @cvar revision: revision of the source, or None to use CHANGES
+    @type revision: varies depending on VC
+
+    @cvar patch: patch applied to the source, or None if no patch
+    @type patch: None or tuple (level diff)
+
+    @cvar changes: the source step should check out hte latest revision
+                   in the given changes
+    @type changes: tuple of L{buildbot.changes.changes.Change} instances,
+                   all of which are on the same branch
+    """
+
+    def canBeMergedWith(self, other):
+        """
+        Can this SourceStamp be merged with OTHER?
+        """
+
+    def mergeWith(self, others):
+        """Generate a SourceStamp for the merger of me and all the other
+        BuildRequests. This is called by a Build when it starts, to figure
+        out what its sourceStamp should be."""
+
+    def getText(self):
+        """Returns a list of strings to describe the stamp. These are
+        intended to be displayed in a narrow column. If more space is
+        available, the caller should join them together with spaces before
+        presenting them to the user."""
 
 class IEmailSender(Interface):
     """I know how to send email, and can be used by other parts of the
@@ -139,6 +169,11 @@
     using the same source tree."""
 
     def getSourceStamp():
+        """Return a SourceStamp object which can be used to re-create
+        the source tree that this build used.
+
+        This method will return None if the source information is no longer
+        available."""
         pass
     def getReason():
         pass
@@ -176,6 +211,11 @@
     finally turned into a Build."""
 
     def getSourceStamp():
+        """Return a SourceStamp object which can be used to re-create
+        the source tree that this build used.
+
+        This method will return None if the source information is no longer
+        available."""
         pass
     def getBuilderName():
         pass
@@ -306,23 +346,14 @@
         added in the future."""
 
     def getSourceStamp():
-        """Return a tuple of (branch, revision, patch) which can be used to
-        re-create the source tree that this build used. 'branch' is a string
-        with a VC-specific meaning, or None to indicate that the checkout
-        step used its default branch. 'revision' is a string, the sort you
-        would pass to 'cvs co -r REVISION'. 'patch' is either None, or a
-        (level, diff) tuple which represents a patch that should be applied
-        with 'patch -pLEVEL < DIFF' from the directory created by the
-        checkout operation.
+        """Return a SourceStamp object which can be used to re-create
+        the source tree that this build used.
 
         This method will return None if the source information is no longer
         available."""
         # TODO: it should be possible to expire the patch but still remember
         # that the build was r123+something.
 
-        # TODO: change this to return the actual SourceStamp instance, and
-        # remove getChanges()
-
     def getChanges():
         """Return a list of Change objects which represent which source
         changes went into the build."""

Index: sourcestamp.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/sourcestamp.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- sourcestamp.py	6 Feb 2007 20:36:09 -0000	1.4
+++ sourcestamp.py	1 Aug 2007 20:31:43 -0000	1.5
@@ -15,7 +15,7 @@
        If REV is None, checkout HEAD and patch it.
      - (revision=None, patchspec=None, changes=[CHANGES]): let the Source
        step check out the latest revision indicated by the given Changes.
-       CHANGES is a list of L{buildbot.changes.changes.Change} instances,
+       CHANGES is a tuple of L{buildbot.changes.changes.Change} instances,
        and all must be on the same branch.
     """
 
@@ -23,7 +23,7 @@
     branch = None
     revision = None
     patch = None
-    changes = []
+    changes = ()
 
     compare_attrs = ('branch', 'revision', 'patch', 'changes')
 
@@ -35,7 +35,7 @@
         self.revision = revision
         self.patch = patch
         if changes:
-            self.changes = changes
+            self.changes = tuple(changes)
             self.branch = changes[0].branch
 
     def canBeMergedWith(self, other):
@@ -80,3 +80,13 @@
                                 changes=changes)
         return newsource
 
+    def getText(self):
+        # TODO: this won't work for VC's with huge 'revision' strings
+        if self.revision is None:
+            return [ "latest" ]
+        text = [ str(self.revision) ]
+        if self.branch:
+            text.append("in '%s'" % self.branch)
+        if self.patch:
+            text.append("[patch]")
+        return text





More information about the Commits mailing list