[PATCH 3 of 4] log: add a marker for closed heads

Gilles Moris gilles.moris at free.fr
Sun May 9 15:50:15 CDT 2010


 mercurial/cmdutil.py                    |  4 +++-
 mercurial/templatekw.py                 |  8 ++++++++
 mercurial/templates/map-cmdline.default |  6 +++---
 tests/test-branches.out                 |  7 ++++---
 4 files changed, 18 insertions(+), 7 deletions(-)


# HG changeset patch
# User Gilles Moris <gilles.moris at free.fr>
# Date 1273437800 -7200
# Node ID 4f227e0671ba95e075ecdc2d2a6b5f3f0072e5bf
# Parent  3615f282d6f08fb99976b86816ff37c019b8187a
log: add a marker for closed heads

diff -r 3615f282d6f0 -r 4f227e0671ba mercurial/cmdutil.py
--- a/mercurial/cmdutil.py	Sun May 09 22:42:06 2010 +0200
+++ b/mercurial/cmdutil.py	Sun May 09 22:43:20 2010 +0200
@@ -737,8 +737,10 @@
         parents = [(p, hexfunc(log.node(p)))
                    for p in self._meaningful_parentrevs(log, rev)]
 
-        self.ui.write(_("changeset:   %d:%s\n") % (rev, hexfunc(changenode)),
+        self.ui.write(_("changeset:   %d:%s") % (rev, hexfunc(changenode)),
                       label='log.changeset')
+        self.ui.write(templatekw.showclosed(ctx=ctx), label='log.closed')
+        self.ui.write("\n")
 
         branch = ctx.branch()
         # don't show the default branch name
diff -r 3615f282d6f0 -r 4f227e0671ba mercurial/templatekw.py
--- a/mercurial/templatekw.py	Sun May 09 22:42:06 2010 +0200
+++ b/mercurial/templatekw.py	Sun May 09 22:43:20 2010 +0200
@@ -6,6 +6,7 @@
 # GNU General Public License version 2 or any later version.
 
 from node import hex
+from i18n import _
 import encoding, patch, util, error
 
 def showlist(name, values, plural=None, **args):
@@ -234,6 +235,12 @@
 def showtags(**args):
     return showlist('tag', args['ctx'].tags(), **args)
 
+def showclosed(**args):
+    if args['ctx'].extra().get('close'):
+        return _(' (closed)')
+    else:
+        return ''
+
 # keywords are callables like:
 # fn(repo, ctx, templ, cache, revcache, **args)
 # with:
@@ -261,5 +268,6 @@
     'node': shownode,
     'rev': showrev,
     'tags': showtags,
+    'closed': showclosed,
 }
 
diff -r 3615f282d6f0 -r 4f227e0671ba mercurial/templates/map-cmdline.default
--- a/mercurial/templates/map-cmdline.default	Sun May 09 22:42:06 2010 +0200
+++ b/mercurial/templates/map-cmdline.default	Sun May 09 22:43:20 2010 +0200
@@ -1,7 +1,7 @@
-changeset = 'changeset:   {rev}:{node|short}\n{branches}{tags}{parents}user:        {author}\ndate:        {date|date}\nsummary:     {desc|firstline}\n\n'
+changeset = 'changeset:   {rev}:{node|short}{closed}\n{branches}{tags}{parents}user:        {author}\ndate:        {date|date}\nsummary:     {desc|firstline}\n\n'
 changeset_quiet = '{rev}:{node|short}\n'
-changeset_verbose = 'changeset:   {rev}:{node|short}\n{branches}{tags}{parents}user:        {author}\ndate:        {date|date}\n{files}{file_copies_switch}description:\n{desc|strip}\n\n\n'
-changeset_debug = 'changeset:   {rev}:{node}\n{branches}{tags}{parents}{manifest}user:        {author}\ndate:        {date|date}\n{file_mods}{file_adds}{file_dels}{file_copies_switch}{extras}description:\n{desc|strip}\n\n\n'
+changeset_verbose = 'changeset:   {rev}:{node|short}{closed}\n{branches}{tags}{parents}user:        {author}\ndate:        {date|date}\n{files}{file_copies_switch}description:\n{desc|strip}\n\n\n'
+changeset_debug = 'changeset:   {rev}:{node}{closed}\n{branches}{tags}{parents}{manifest}user:        {author}\ndate:        {date|date}\n{file_mods}{file_adds}{file_dels}{file_copies_switch}{extras}description:\n{desc|strip}\n\n\n'
 start_files = 'files:      '
 file = ' {file}'
 end_files = '\n'
diff -r 3615f282d6f0 -r 4f227e0671ba tests/test-branches.out
--- a/tests/test-branches.out	Sun May 09 22:42:06 2010 +0200
+++ b/tests/test-branches.out	Sun May 09 22:43:20 2010 +0200
@@ -157,7 +157,7 @@
 default                        0:19709c5a4e75 (inactive)
 a branch name much longer than the default justification used by branches 7:10ff5895aa57
 no open branch heads found on branches b
-changeset:   12:2da6583810df
+changeset:   12:2da6583810df (closed)
 branch:      b
 tag:         tip
 parent:      8:eebb944467c9
@@ -165,12 +165,13 @@
 date:        Thu Jan 01 00:00:09 1970 +0000
 summary:     close this part branch too
 
-changeset:   11:c84627f3c15d
+changeset:   11:c84627f3c15d (closed)
 branch:      b
 user:        test
 date:        Thu Jan 01 00:00:09 1970 +0000
 summary:     prune bad branch
 
+resurrecting closed changeset 12
 --- branch b is back in action
 b                             13:6ac12926b8c3
 a branch name much longer than the default justification used by branches 7:10ff5895aa57
@@ -236,7 +237,7 @@
 date:        Thu Jan 01 00:00:09 1970 +0000
 summary:     reopen branch with a change
 
-changeset:   11:c84627f3c15d
+changeset:   11:c84627f3c15d (closed)
 branch:      b
 user:        test
 date:        Thu Jan 01 00:00:09 1970 +0000


More information about the Mercurial-devel mailing list