From: Eric S. Raymond Date: Fri, 21 Nov 2014 13:12:15 +0000 (-0500) Subject: Show branch for each revision in the log listing. Regression test passes. X-Git-Tag: 0.12~2 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=bc4eb405473276043cbe8fdbfb32ad931cde1246;p=src.git Show branch for each revision in the log listing. Regression test passes. --- diff --git a/NEWS b/NEWS index 328d51b..dc4ba2e 100644 --- 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 02a760d..c74bb3f 100644 --- 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 f0946c0..2b553e3 100755 --- 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 2d00f92..094a278 100755 --- a/srctest +++ b/srctest @@ -77,10 +77,10 @@ check "list test" cat >testfile2 <testfile4 <sample.seqlog <sample.branchlog <newlog <