]> thyrsus.com Git - src.git/commitdiff
Attempted (not yet tested) switch to using sticky tags.
authorEric S. Raymond <esr@thyrsus.com>
Mon, 10 Nov 2014 20:03:12 +0000 (15:03 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Mon, 10 Nov 2014 20:03:12 +0000 (15:03 -0500)
Regression test passes.

src

diff --git a/src b/src
index 7d5ca87d084353b626303ee9a130afff5745a7f9..dc70cc446359bf964f2dfa065c98277bc1b406c5 100755 (executable)
--- a/src
+++ b/src
@@ -21,6 +21,9 @@
 # thus, to distinguish between U and M status all we need to do is compare
 # modtimes.
 #
+# This code uses magic tags with a 0 in the second-to-last slot to designate
+# branches.  It's the same format as CVS sticky tags.
+#
 import sys, os, subprocess, time, calendar, stat, glob
 
 version=0.3
@@ -924,7 +927,10 @@ class RCS:
     def set_branch(self, name, revision, metadata, arg):
         "Set the specified branch to be default, creating it if required."
         if name in metadata.symbols:
-            base = metadata.symbols[name]
+            # Must unstickify...
+            base = metadata.symbols[name].split(".")
+            base = base[:-2] + base[-1:]
+            base = ".".join(base)
         else:
             def branchfrom(c, p):
                 "Is c a branch child (not direct descendant) of parent p?"
@@ -932,15 +938,11 @@ class RCS:
                 p = p.split(".")
                 return len(c) == len(p) + 2 and c[len(p):] == p
             baserev = metadata.current()
-            print "Beginning branch computation from", baserev
             newsib = len([item for item in metadata.revlist \
                          if branchfrom(item.revision, baserev)])
-            print "Continuing branch computation"
-            # Use CVS sticky-tag format here? If so, we'd have to do
-            # some unscrambling just above in the non-new case
             base = baserev + "." + str(newsib)
-            print "New branch", base
-            do_or_die("rcs -n{0}:{1} {2}".format(name, base, arg), loud=True)
+            sticky = baserev + ".0." + str(newsib)
+            do_or_die("rcs -n{0}:{1} {2}".format(name, sticky, arg), loud=True)
         do_or_die("rcs -b%s %s" % (base, arg), loud=True)
     def move(self, source, target):
         "Move a file and its history."
@@ -987,7 +989,11 @@ class RCS:
                         state = "symbols"
                     elif line.startswith("branch:"):
                         branch = line.split(":")[1].strip()
-                        if not branch:
+                        # Undocumented fact about RCS: The branch "1" is
+                        # the same as the blank branch.  Significant because
+                        # you can't reset to the blank branch using rcs -b,
+                        # that resets to the dynamically hhighest branch.
+                        if not branch or branch == "1":
                             metadata.branch = "trunk"
                     elif line.startswith("----------------------------"):
                         if debug >= DEBUG_PARSE:
@@ -1055,8 +1061,8 @@ class RCS:
                 print "\tlockrevs:", metadata.lockrevs
                 print "\tsymbols:", metadata.symbols
     def branch_to_base(self, revid):
-        "Go from a branch ID to the revision it was based on."
-        return ".".join(revid.split(".")[:-1])
+        "Go from a branch ID sticky tag to the revision it was based on."
+        return ".".join(revid.split(".")[:-2])
 
 if __name__ == "__main__":
     try: