changeset 23876:48fd1dfb99aa

log: use namespace logname and colorname Now that we have the machinary to change the log name and the color label used, let's use that. Tests have been updated accordingly.
author Sean Farley <sean.michael.farley@gmail.com>
date Wed, 14 Jan 2015 20:29:47 -0800
parents e573dd08aeaf
children 7cc77030c557
files mercurial/cmdutil.py tests/test-log.t
diffstat 2 files changed, 19 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Wed Jan 14 20:11:02 2015 -0800
+++ b/mercurial/cmdutil.py	Wed Jan 14 20:29:47 2015 -0800
@@ -920,8 +920,8 @@
             # should be the same
             for name in ns.names(self.repo, changenode):
                 # i18n: column positioning for "hg log"
-                tname = _(("%s:" % ns.templatename).ljust(13) + "%s\n") % name
-                self.ui.write("%s" % tname, label='log.%s' % ns.templatename)
+                name = _(("%s:" % ns.logname).ljust(13) + "%s\n") % name
+                self.ui.write("%s" % name, label='log.%s' % ns.colorname)
         if self.ui.debugflag:
             # i18n: column positioning for "hg log"
             self.ui.write(_("phase:       %s\n") % _(ctx.phasestr()),
--- a/tests/test-log.t	Wed Jan 14 20:11:02 2015 -0800
+++ b/tests/test-log.t	Wed Jan 14 20:29:47 2015 -0800
@@ -1571,8 +1571,9 @@
   >     namemap = lambda r, name: foo.get(name)
   >     nodemap = lambda r, node: [name for name, n in foo.iteritems()
   >                                if n == node]
-  >     ns = namespace("bars", templatename="bar", listnames=names,
-  >                    namemap=namemap, nodemap=nodemap)
+  >     ns = namespace("bars", templatename="bar", logname="barlog",
+  >                    colorname="barcolor", listnames=names, namemap=namemap,
+  >                    nodemap=nodemap)
   > 
   >     repo.names.addnamespace(ns)
   > EOF
@@ -1580,11 +1581,24 @@
   $ hg --config extensions.names=../names.py log -r 0
   changeset:   0:65624cd9070a
   tag:         tip
-  bar:         foo
+  barlog:      foo
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     a bunch of weird directories
   
+  $ hg --config extensions.names=../names.py \
+  >  --config extensions.color= --config color.log.barcolor=red \
+  >  --color=always log -r 0
+  \x1b[0;33mchangeset:   0:65624cd9070a\x1b[0m (esc)
+  tag:         tip
+  \x1b[0;31mbarlog:      foo\x1b[0m (esc)
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     a bunch of weird directories
+  
+  $ hg --config extensions.names=../names.py log -r 0 --template '{bars}\n'
+  foo
+
   $ cd ..
 
 hg log -f dir across branches