]> thyrsus.com Git - src.git/commitdiff
Very beginnings of branch implementation.
authorEric S. Raymond <esr@thyrsus.com>
Sat, 8 Nov 2014 16:32:46 +0000 (11:32 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Sat, 8 Nov 2014 16:32:46 +0000 (11:32 -0500)
src

diff --git a/src b/src
index 6f26d19c25463687d726b0597735c79f282e0898..dc54a1bd14a2f74f7bb1aeec7c431c28b90641ab 100755 (executable)
--- a/src
+++ b/src
@@ -117,7 +117,7 @@ class RCSRevisionItem:
 def master(arg):
     return os.path.join(repodir, arg + ",v")
 
-class RCSLog:
+class History:
     "Encapsulate a revision list and some methods on it"
     def __init__(self, name):
         self.name = name
@@ -245,6 +245,9 @@ class RCSLog:
         if end > len(self):
             croak("{0} has no {1} revision".format(self.name, end))
         return range(start, end+1) 
+    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."
@@ -438,7 +441,7 @@ def commit_method(*args):
        elif not os.path.exists(master(arg)):
            croak("%s is not registered." % arg)
        else:
-           metadata = RCSLog(arg)
+           metadata = History(arg)
            if not comment:
                editor = os.getenv("EDITOR") or "emacsclient"
                commentfile = "/tmp/src%dtmp" % os.getpid()
@@ -461,7 +464,7 @@ def list_method(*args):
     width = screenwidth()
     for arg in args:
         sys.stdout.write("= %s %s\n" % (arg, ((width - len(arg) - 5) * "=")))
-        master = RCSLog(arg)
+        master = History(arg)
         revspec = master.resolve(revspec)
         for item in master:
             if not revspec or item.revno in revspec:
@@ -480,7 +483,7 @@ def log_method(*args):
     width = screenwidth()
     for arg in args:
         sys.stdout.write("= %s %s\n" % (arg, ((width - len(arg) - 5) * "=")))
-        master = RCSLog(arg)
+        master = History(arg)
         revspec = master.resolve(revspec)
         for item in master:
             if not revspec or item.revno in revspec:
@@ -493,7 +496,7 @@ def checkout_method(*args):
     if revspec and revspec[0] != revspec[1]:
         croak("checkout needs an empty or singleton revision spec")
     for arg in args:
-        master = RCSLog(arg)
+        master = History(arg)
         revspec = master.resolve(revspec)
         if revspec is None:
             revspec = [len(master)]
@@ -513,7 +516,7 @@ def cat_method(*args):
     "Dump revision content to standard output."
     (revspec, args) = preamble("cat", args)
     for arg in args:
-        master = RCSLog(arg)
+        master = History(arg)
         revspec = master.resolve(revspec)
         if revspec is None:
             revspec = [master.tip().revno]
@@ -531,7 +534,7 @@ def diff_method(*args):
     for arg in args:
         diffspec = ""
         if revspec is not None:
-            master = RCSLog(arg)
+            master = History(arg)
             revspec = master.resolve(revspec)
             diffspec += "-r" + master.revno_to_rcs(revspec[0])
             if len(revspec) > 1:
@@ -546,10 +549,11 @@ def list_tags(*args):
         croak("can't accept a revision-spec when deleting tags.")
     width = screenwidth()
     for arg in args:
-        master = RCSLog(arg)
+        master = History(arg)
         sys.stdout.write("= %s %s\n" % (arg, ((width - len(arg) - 5) * "=")))
         for (key, value) in master.symbols.items():
-            sys.stdout.write("%4d      %s\n" % (master.rcs_to_revno(value),key))
+            if not master.isbranch(arg):
+                sys.stdout.write("%4d\t%s\n" % (master.rcs_to_revno(value),key))
 
 def delete_tags(args):
     if not args:
@@ -559,7 +563,7 @@ def delete_tags(args):
     if revspec is not None:
         croak("can't accept a revision-spec when deleting tags.")
     for arg in args:
-        master = RCSLog(arg)
+        master = History(arg)
         if tagname not in master.symbols:
             croak("%s is not a tag in %s" % (tagname, arg))
         else:
@@ -574,7 +578,7 @@ def set_tags(args):
     tagname = args.pop(0)
     (revspec, args) = preamble("tag", args)
     for arg in args:
-        master = RCSLog(arg)
+        master = History(arg)
         revspec = master.resolve(revspec)
         if revspec is None:
             revision = master.tip().revision
@@ -607,6 +611,13 @@ def tag_method(*args):
             return
     set_tags(args)
 
+def branch_method(*args):
+    "Inspect, create, and delete branch."
+    if not os.path.exists(repodir):
+        croak("repository subdirectory %s does not exist" % repodir)
+    args = list(args)
+    croak("branches are not yet implemented.")
+
 def fast_export_method(*args):
     "Dump revision content to standard output."
     (revspec, args) = preamble("cat", args)
@@ -628,7 +639,7 @@ def fast_export_method(*args):
             perms = "100755"
         else:
             perms = "100644"
-        metadata = RCSLog(arg)
+        metadata = History(arg)
         revspec = metadata.resolve(revspec)
         if revspec is None:
             revspec = 1
@@ -736,6 +747,7 @@ dispatch = {
     "cat":         cat_method,
     "diff":        diff_method,
     "tag":         tag_method,
+    "branch":      branch_method,
     "fast-export": fast_export_method,
     "moveto":      moveto_method,
     "copyto":      copyto_method,