]> thyrsus.com Git - rcs-fast-import.git/commitdiff
Tags are working.
authorEric S. Raymond <esr@thyrsus.com>
Thu, 11 Nov 2010 14:05:27 +0000 (09:05 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Thu, 11 Nov 2010 14:05:27 +0000 (09:05 -0500)
rcs-fast-import

index ea348595140f07814460f4910a01a1a1ba62caac..cdc2840bccae536f9ea25f371d100244a1f2e42b 100755 (executable)
@@ -6,10 +6,9 @@
 #
 # Requires Python 2.5 or newer.
 #
-#
 # TO DO:
-#   * Apply tags
 #   * Branch structure!
+#   * Checkout options
 #
 """
 Usage: rcs-fast-import [-v] [-u] [-l] [-d] [-n] [-V] 
@@ -216,6 +215,7 @@ class Commit:
         self.branch = None           # branch name
         self.fileops = []            # blob and file operation list
         self.properties = {}         # commit properties (extension)
+        self.taglist = []            # Tags that point at this commit
 
 class Passthrough:
     "Represents a passthrough line."
@@ -270,6 +270,9 @@ class Repository:
             if hasattr(e, "mark") and mark == e.mark:
                 return i
         return None
+    def commits(self):
+        "Return a list of the repository commit objects."
+        return filter(lambda e: isinstance(e, Commit), self.events)
     def fast_import(self, fp, progress=False):
         "Initialize repo object from fast-import stream."
         try:
@@ -461,8 +464,11 @@ class Repository:
                             self.warn("missing tagger after from in tag")
                             pushback(line)
                         dp = read_data(cStringIO.StringIO())
-                        self.events.append(Tag(tagname,
-                                               referent, tagger, dp.getvalue()))
+                        tag = Tag(tagname, referent, tagger, dp.getvalue())
+                        self.events.append(tag)
+                        for commit in self.commits():
+                            if commit.mark == referent:
+                                commit.taglist.append(tag)
                         baton.twirl()
                     else:
                         # Simply pass through any line we don't understand.
@@ -550,6 +556,15 @@ class RCS:
         parts = list(os.path.split(filename))
         parts.insert(-1, "RCS")
         return os.path.join(*parts)
+    @staticmethod
+    def rcsfiles():
+        "List all masters."
+        res = []
+        for root, dirs, files in os.walk(os.getcwd(), topdown=False):
+            if root.endswith("/RCS"):
+                for name in files:
+                    res.append(os.path.join(root, name))
+        return res
     def commit(self, event, committables):
         "Perform RCS file checkins and modifications,"
         for (path, mode, copyfile) in committables:
@@ -581,6 +596,8 @@ class RCS:
                     announce("removing %s" % (path,))
                 if not dryrun:
                     os.remove(path)
+        for tag in event.taglist:
+            do_or_die("rcs -n'%s': %s" % (tag.name, " ".join(RCS.rcsfiles())))
     def rename(self, source, target):
         "Perform RCS renames."
         # Dodgy, but since user is more likely to be