]> thyrsus.com Git - src.git/commitdiff
Move a method.
authorEric S. Raymond <esr@thyrsus.com>
Thu, 13 Nov 2014 11:59:01 +0000 (06:59 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Thu, 13 Nov 2014 11:59:01 +0000 (06:59 -0500)
src

diff --git a/src b/src
index 4d96f8d033ae1590268bc8e0ef2392a9bbba1a2c..be47fe1d4bc18b4b6cca91948129cba65e245994 100755 (executable)
--- a/src
+++ b/src
 # 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.
+# branches.  It's the same format as CVS sticky tags, for the same reason.
+# They need to be distinguishable from regular tags pointing at revisions,
+# and this way the code to transform the sticky tag into the branch name is
+# as simple as possible.
 #
 # Top of the list of things that people will bikeshed about is the
 # letter codes returned by src status. Different VCSes have
@@ -237,9 +240,6 @@ class History:
             if item.revno == revno:
                 return item.revision
         croak("{0} has no revno {1}".format(self.name, revno))
-    def isbranch(self, symbol):
-        "Is this a branch symbol?"
-        return "0." in symbol
 
 def help_method(*_args):
     "Summarize src commands, or (with argument) show help for a single command."
@@ -457,7 +457,7 @@ class CommandContext:
                 croak("in {0}, can't resolve symbol {0}".format(metadata.name,token))
             else:
                 part = metadata.symbols[part]
-            if metadata.isbranch(part):
+            if backend.isbranch(part):
                 part = backend.branch_to_tip(part)
             return metadata.native_to_revno(part)
             croak("internal error: in %s, failed to resolve %s" % (metadata.name, token))         
@@ -798,7 +798,7 @@ def tag_helper(args, legend, validation_hook, delete_method, set_method):
                             display = metadata.native_to_revno(display)
                     else:
                         display = metadata.native_to_revno(value)
-                    if metadata.isbranch(value) == (legend == "branch"):
+                    if backend.isbranch(value) == (legend == "branch"):
                         sys.stdout.write("%4s\t%s\n" % (display,key))
             return
         if args[0] in ("-r", "rename"):
@@ -1081,6 +1081,9 @@ class RCS:
         n = self.splitrev(rev)
         n[-1] += 1
         return self.joinrev(n)
+    def isbranch(self, symbol):
+        "Is this a branch symbol?"
+        return "0." in symbol
     def branch_to_base(self, revid):
         "Go from a branch ID sticky tag to the revision it was based on."
         # Must return an emptry string for the fake root sticky tag.
@@ -1193,7 +1196,7 @@ class RCS:
                         # 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.
+                        # that resets to the dynamically highest branch.
                         if not branch or branch == "1":
                             metadata.branch = "trunk"
                     elif line.startswith("----------------------------"):