]> thyrsus.com Git - rcs-fast-import.git/commitdiff
Write tags. Still have to do lightweight tags from resets.
authorEric S. Raymond <esr@thyrsus.com>
Sun, 14 Nov 2010 05:36:46 +0000 (00:36 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Sun, 14 Nov 2010 05:36:46 +0000 (00:36 -0500)
rcs-fast-import

index a081c88f067d829aaa5e2d91f43e3ac7ca9f4864..988b08dbd3494cf33587f896d1d9f4e51c37124b 100755 (executable)
@@ -608,9 +608,12 @@ class GenericRev:
         s = GenericRev(self.rev)
         s.rev[-1] += 1
         return s
-    def branch(self, branchnum):
-        "Return ID for the tip of a new branch."
-        return GenericRev(self.rev + [branchnum, 1])
+    def branch(self, branchnum=None):
+        "With arg, return ID for the tip of a new branch."
+        if branchnum is None:
+            return GenericRev(self.rev[:-1])
+        else:
+            return GenericRev(self.rev + [branchnum, 1])
     def __str__(self):
         return ".".join(map(str, self.rev))
 
@@ -699,8 +702,11 @@ class Generic:
             comment = event.email_out()
         else:
             comment = event.comment
-        do_or_die(self.checkin(commit, comment, op, path), legend)
+        rev = self.make_tip(commit, path)
+        do_or_die(self.checkin(commit, comment, op, path, rev), legend)
         loud_remove(path)
+        if commit.is_tip():
+            self.maketag(commit.branch, str(rev.branch()), path)
     def modify(self, event, path, mode, copyfile):
         "Perform file checkins and modifications,"
         sanecheck(event, path, mode, copyfile)
@@ -734,9 +740,9 @@ class RCS(Generic):
     mastertemplate = "%s,v"
     def __init__(self):
         Generic.__init__(self)
-    def checkin(self, commit, comment, op, path):
+    def checkin(self, commit, comment, op, path, rev):
         "Check in a new revision - also used to create new masters."
-        command = "ci -l%s" % self.make_tip(commit, path)
+        command = "ci -l%s" % rev
         if op == "D":
             command += " -sDeleted"
         command += " -d'%s'" % commit.committer.date.rfc822()
@@ -746,6 +752,9 @@ class RCS(Generic):
     def checkout(self, path, branch):
         "Check out the latest revision corresponding to path and branch."
         return "co -r%s %s" % (self.get_tip(path, branch), self.master(path))
+    def maketag(self, name, rev, path):
+        "Attach a tag to a file, overwriting any previous."
+        do_or_die("rcs -N'%s':%s %s" % (name, rev, self.master(path)))
     def postcommit(self, event):
         "Save annotated tags for round-tripping."
         for tag in event.taglist: