hg log to print parent with branch names

Stepan Koltsov yozh at mx1.ru
Fri Dec 5 15:16:29 CST 2008


Hi, all. This is my first message to mercurial-devel@ mailing list.

I've created a feature request in the Mercurial issue tracker:

http://www.selenic.com/mercurial/bts/issue1414

I requested modification of hg log output, to print parent branch name
in addition to parent rev and node. So output could be something like
this:

===
changeset:   887:bd3da2ce3610
branch:      r2199-all
tag:         tip
parent:      885:dd0fed14aec7
parent:      886:a18d4114c86b (r2199-debian)  <--- parent branch is
printed only if different
user:        Stepan Koltsov <stepancheg at yandex-team.ru>
date:        Wed Dec 03 22:02:38 2008 +0300
summary:     merge r2199-debian (ccache as dependency)
===

Matt Mackall rejected my proposal, because it breaks backward
compatibility with programs that parse text output of hg log command.

So I proposed a patch to Mercurial templaing:

===
diff -r 6aafd75fb924 mercurial/cmdutil.py
--- a/mercurial/cmdutil.py	Tue Dec 02 13:06:18 2008 -0600
+++ b/mercurial/cmdutil.py	Fri Dec 05 21:06:33 2008 +0000
@@ -790,7 +790,7 @@ class changeset_templater(changeset_prin
                 return showlist('branch', [branch], plural='branches', **args)

         def showparents(**args):
-            parents = [[('rev', p), ('node', hex(log.node(p)))]
+            parents = [[('rev', p), ('node', hex(log.node(p))),
('branch', log.read(log.node(p))[5].get("branch"))]
                        for p in self._meaningful_parentrevs(log, rev)]
             return showlist('parent', parents, **args)

===

Users can write templates (simplified version):

===
changeset = "cs:     {rev}:{node|short}\nbranch: {branches}\n{parents}\n"
parent    = "parent: {rev}:{node|short} ({branch})\n"
===

This template always prints parent branch (even if is is equal to
context branch), however this is acceptable to me.

Matt Mackall asked to post this request to the mailing list.

Anyway, I'm happy Mercurial users, thank you all.

S.


More information about the Mercurial-devel mailing list