]> thyrsus.com Git - src.git/commitdiff
Show branch for each revision in the log listing. Regression test passes.
authorEric S. Raymond <esr@thyrsus.com>
Fri, 21 Nov 2014 13:12:15 +0000 (08:12 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Fri, 21 Nov 2014 13:12:15 +0000 (08:12 -0500)
NEWS
TODO
src
srctest

diff --git a/NEWS b/NEWS
index 328d51b757b8c7ba6fc1e118bfe36f1970f4ba4f..dc4ba2e4a2ae19d0ea0d3ff746d2dddd88630d3a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,7 +1,8 @@
                        src project news
 
 Repository head:
-   List and log command now have an -l option to play nice with Emacs VC
+   Log command shows the branch in the header line for each revision
+   List and log command now have an -l option to play nice with Emacs VC.
 
 0.11: 2014-11-19
    File-not-modified status character changed to '=' to match Mercurial.
diff --git a/TODO b/TODO
index 02a760d7110c547cafe8eba5662fa77a356d84bc..c74bb3fbe5bc30a2c7b18fad9373d788ec437ee5 100644 (file)
--- a/TODO
+++ b/TODO
@@ -6,8 +6,6 @@
 
 * should be possible to range-restrict a tag or branch listing.
 
-* Show branch in log listings
-
 * Branch tree visualization with DOT.
 
 * Parse RCS files directly rather than relying on rlog(1).
diff --git a/src b/src
index f0946c069aa74f430bb4f2f84319196815c72d01..2b553e39bf2ded6f2e31686abe60d4fa1fc94f35 100755 (executable)
--- a/src
+++ b/src
@@ -237,6 +237,7 @@ class HistoryEntry:
         self.parent = None
         self.child = None
         self.branches = set([])
+        self.branch = None
     def selected(self):
         return self == self.history.current()
     def unixtime(self):
@@ -275,6 +276,15 @@ class History:
             item.child  = self.by_native_d.get(backend.succ(item.native))
             if item.parent and item.parent.child != item:
                 item.parent.branches.add(item)
+        for (name, rev) in self.symbols.items():
+            if backend.isbranch(rev):
+                base = backend.branch_to_base(rev, self)
+                tip = backend.branch_to_tip(rev, self)
+                while True:
+                    self.by_native_d[base].branch = name
+                    if base == tip:
+                        break
+                    base = backend.succ(base)
         #for item in self.revlist:
         #    print item
         #print self.by_revno_d.keys()
@@ -1190,7 +1200,8 @@ def log_method(*args):
             continue
         sys.stdout.write("= %s %s\n" % (arg, ((WIDTH - len(arg) - 3) * "=")))
         for item in ctx.resolve(History(arg), backwards=True):
-            sys.stdout.write("%-4d | %s\n%s" % (item.revno,item.date,item.log))
+            sys.stdout.write("%-4d | %s | %s\n%s" \
+                             % (item.revno, item.date, item.branch, item.log))
             sys.stdout.write(("-" * WIDTH) + "\n")
             if limit is not None:
                 limit -= 1
@@ -1347,10 +1358,10 @@ def tag_helper(args, legend, validation_hook, delete_method, set_method):
                 for key in keys:
                     value = metadata.symbols[key]
                     if legend == "branch":
-                        # Note! This code relies on backend.branch_to_base()
+                        # Note! This code relies on backend.branch_to_parent()
                         # returning an empty string when called on a trunk
                         # revision.
-                        display = backend.branch_to_base(value)
+                        display = backend.branch_to_parent(value)
                         if not display:
                             display = 0
                         else:
@@ -1663,17 +1674,21 @@ class RCS:
     def isbranch(self, symbol):
         "Is this a branch symbol?"
         return "0." in symbol
-    def branch_to_base(self, revid):
+    def branch_to_parent(self, revid):
         "Go from a branch ID sticky tag to the revision it was based on."
         # Must return an empty string for the fake root sticky tag.
         return self.joinrev(self.splitrev(revid)[:-2])
-    def branch_to_tip(self, revid, metadata):
-        "Go from a branch ID sticky tag to the tip revision of its base."
-        rev = self.branch_to_base(revid)
+    def branch_to_base(self, revid, metadata):
+        "Go from a branch ID sticky tag to the first revision of its branch."
+        rev = self.branch_to_parent(revid)
         if rev:
             rev += ".1.1"
         else:
             rev = "1.1"
+        return rev
+    def branch_to_tip(self, revid, metadata):
+        "Go from a branch ID sticky tag to the tip revision of its branch."
+        rev = self.branch_to_base(revid, metadata)
         while True:
             nxt = self.succ(rev)
             if metadata.native_to_revno(nxt) is None:
diff --git a/srctest b/srctest
index 2d00f92638fa633105880be301bbe6670056fa3f..094a278332d20b79db3c2b0d72c8fd826b83d52b 100755 (executable)
--- a/srctest
+++ b/srctest
@@ -77,10 +77,10 @@ check "list test"
 
 cat >testfile2 <<EOF
 = testfile1 ============================================================
-2    | 1970-01-02T00:01:00Z
+2    | 1970-01-02T00:01:00Z | trunk
 Second comment
 ------------------------------------------------------------------------
-1    | 1970-01-02T00:00:00Z
+1    | 1970-01-02T00:00:00Z | trunk
 First comment
 ------------------------------------------------------------------------
 EOF
@@ -103,13 +103,13 @@ check "commit with -f"
 
 cat >testfile4 <<EOF
 = testfile1 ============================================================
-3    | 1970-01-02T00:02:00Z
+3    | 1970-01-02T00:02:00Z | trunk
 'Third' comment
 ------------------------------------------------------------------------
-2    | 1970-01-02T00:01:00Z
+2    | 1970-01-02T00:01:00Z | trunk
 Second comment
 ------------------------------------------------------------------------
-1    | 1970-01-02T00:00:00Z
+1    | 1970-01-02T00:00:00Z | trunk
 First comment
 ------------------------------------------------------------------------
 EOF
@@ -468,19 +468,19 @@ EOF
 
 cat >sample.seqlog <<EOF
 = sample ===============================================================
-6    | 1970-01-02T00:05:00Z
+6    | 1970-01-02T00:05:00Z | muggle
 Still utterly fubar
 ------------------------------------------------------------------------
-5    | 1970-01-02T00:04:00Z
+5    | 1970-01-02T00:04:00Z | muggle
 Totally unfubared.
 ------------------------------------------------------------------------
-4    | 1970-01-02T00:03:00Z
+4    | 1970-01-02T00:03:00Z | trunk
 On a branch?
 ------------------------------------------------------------------------
-3    | 1970-01-02T00:02:00Z
+3    | 1970-01-02T00:02:00Z | trunk
 Third comment.
 ------------------------------------------------------------------------
-2    | 1970-01-02T00:01:00Z
+2    | 1970-01-02T00:01:00Z | trunk
 Second comment.
 ------------------------------------------------------------------------
 EOF
@@ -491,16 +491,16 @@ check "traversal by -"
 
 cat >sample.branchlog <<EOF
 = sample ===============================================================
-6    | 1970-01-02T00:05:00Z
+6    | 1970-01-02T00:05:00Z | muggle
 Still utterly fubar
 ------------------------------------------------------------------------
-5    | 1970-01-02T00:04:00Z
+5    | 1970-01-02T00:04:00Z | muggle
 Totally unfubared.
 ------------------------------------------------------------------------
-3    | 1970-01-02T00:02:00Z
+3    | 1970-01-02T00:02:00Z | trunk
 Third comment.
 ------------------------------------------------------------------------
-2    | 1970-01-02T00:01:00Z
+2    | 1970-01-02T00:01:00Z | trunk
 Second comment.
 ------------------------------------------------------------------------
 EOF
@@ -593,40 +593,40 @@ check "branch list check after delete" delete
 
 cat >newlog <<EOF
 = sample ===============================================================
-12   | 1970-01-02T00:11:00Z
+12   | 1970-01-02T00:11:00Z | sample
 I see you
 ------------------------------------------------------------------------
-11   | 1970-01-02T00:10:00Z
+11   | 1970-01-02T00:10:00Z | sample
 That's good.
 ------------------------------------------------------------------------
-10   | 1970-01-02T00:09:00Z
+10   | 1970-01-02T00:09:00Z | sample
 No good.
 ------------------------------------------------------------------------
-9    | 1970-01-02T00:08:00Z
+9    | 1970-01-02T00:08:00Z | sample
 It' all good.
 ------------------------------------------------------------------------
-8    | 1970-01-02T00:07:00Z
+8    | 1970-01-02T00:07:00Z | sample
 All fixed up.
 ------------------------------------------------------------------------
-7    | 1970-01-02T00:06:00Z
+7    | 1970-01-02T00:06:00Z | muggle
 Utterly fubar
 ------------------------------------------------------------------------
-6    | 1970-01-02T00:05:00Z
+6    | 1970-01-02T00:05:00Z | muggle
 Totally chenille.
 ------------------------------------------------------------------------
-5    | 1970-01-02T00:04:00Z
+5    | 1970-01-02T00:04:00Z | muggle
 Still utterly fubar
 ------------------------------------------------------------------------
-4    | 1970-01-02T00:03:00Z
+4    | 1970-01-02T00:03:00Z | muggle
 Totally unfubared.
 ------------------------------------------------------------------------
-3    | 1970-01-02T00:02:00Z
+3    | 1970-01-02T00:02:00Z | trunk
 Third comment.
 ------------------------------------------------------------------------
-2    | 1970-01-02T00:01:00Z
+2    | 1970-01-02T00:01:00Z | trunk
 Second comment.
 ------------------------------------------------------------------------
-1    | 1970-01-02T00:00:00Z
+1    | 1970-01-02T00:00:00Z | trunk
 First comment.
 ------------------------------------------------------------------------
 EOF