Patchwork [2,of,6] templates: change default style to display p1rev/node with "+" for wdir

login
register
mail settings
Submitter Yuya Nishihara
Date July 2, 2015, 3:17 p.m.
Message ID <8f50b986609b29dd2804.1435850221@mimosa>
Download mbox | patch
Permalink /patch/9872/
State Accepted
Headers show

Comments

Yuya Nishihara - July 2, 2015, 3:17 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1426333001 -32400
#      Sat Mar 14 20:36:41 2015 +0900
# Node ID 8f50b986609b29dd28049ce145e39c3671c78c37
# Parent  cf8091ddb4c8555580d64e352581689d2901d478
templates: change default style to display p1rev/node with "+" for wdir

This is what cmdutil.changeset_printer does. The default template should
do the same way.

Because wdir() is still experimental, the output of "log -r'wdir()' -Tdefault"
may change in future.
Yuya Nishihara - July 3, 2015, 12:15 p.m.
On Fri, 03 Jul 2015 00:17:01 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1426333001 -32400
> #      Sat Mar 14 20:36:41 2015 +0900
> # Node ID 8f50b986609b29dd28049ce145e39c3671c78c37
> # Parent  cf8091ddb4c8555580d64e352581689d2901d478
> templates: change default style to display p1rev/node with "+" for wdir
> 
> This is what cmdutil.changeset_printer does. The default template should
> do the same way.
> 
> Because wdir() is still experimental, the output of "log -r'wdir()' -Tdefault"
> may change in future.
> 
> diff --git a/mercurial/templates/map-cmdline.default b/mercurial/templates/map-cmdline.default
> --- a/mercurial/templates/map-cmdline.default
> +++ b/mercurial/templates/map-cmdline.default
> @@ -29,19 +29,25 @@ lfile_copies_switch = '{if(file_copies_s
>  
>  # General templates
>  cset = '{label("log.changeset changeset.{phase}",
> -               "changeset:   {rev}:{node|short}")}\n'
> +               "changeset:   {ifeq(node, 'ffffffffffffffffffffffffffffffffffffffff',
> +                                   '{p1rev}:{p1node|short}+',
> +                                   '{rev}:{node|short}')}")}\n'

Please disregard the PATCH 2. The other patches can be applied without this.

I think I should rewrite changeset_printer to eliminate this kind of "if"s.

% hg log -r'wdir()'
changeset:   2147483647:ffffffffffff
parent:      29917:d3d2ba265e17
...

Patch

diff --git a/mercurial/templates/map-cmdline.default b/mercurial/templates/map-cmdline.default
--- a/mercurial/templates/map-cmdline.default
+++ b/mercurial/templates/map-cmdline.default
@@ -29,19 +29,25 @@  lfile_copies_switch = '{if(file_copies_s
 
 # General templates
 cset = '{label("log.changeset changeset.{phase}",
-               "changeset:   {rev}:{node|short}")}\n'
+               "changeset:   {ifeq(node, 'ffffffffffffffffffffffffffffffffffffffff',
+                                   '{p1rev}:{p1node|short}+',
+                                   '{rev}:{node|short}')}")}\n'
 
 lphase = '{label("log.phase",
                  "phase:       {phase}")}\n'
 
 fullcset = '{label("log.changeset changeset.{phase}",
-                   "changeset:   {rev}:{node}")}\n'
+                   "changeset:   {ifeq(node, 'ffffffffffffffffffffffffffffffffffffffff',
+                                       '{p1rev}:{p1node}+',
+                                       '{rev}:{node}')")}\n'
 
 parent = '{label("log.parent changeset.{phase}",
                   "parent:      {rev}:{node|formatnode}")}\n'
 
 lnode = '{label("log.node",
-                "{rev}:{node|short}")}\n'
+                "{ifeq(node, 'ffffffffffffffffffffffffffffffffffffffff',
+                       '{p1rev}:{p1node|short}+',
+                       '{rev}:{node|short}')")}\n'
 
 manifest = '{label("ui.debug log.manifest",
                    "manifest:    {rev}:{node}")}\n'
diff --git a/tests/test-command-template.t b/tests/test-command-template.t
--- a/tests/test-command-template.t
+++ b/tests/test-command-template.t
@@ -174,6 +174,26 @@  as default style, except for extra phase
   $ hg log --debug -T phases > phases.out
   $ cmp log.out phases.out || diff -u log.out phases.out
 
+Default style of working-directory revision should also be the same (but
+date may change while running tests):
+
+  $ hg log -r 'wdir()' | sed 's|^date:.*|date:|' > log.out
+  $ hg log -r 'wdir()' --style default | sed 's|^date:.*|date:|' > style.out
+  $ cmp log.out style.out || diff -u log.out style.out
+
+  $ hg log -r 'wdir()' -v | sed 's|^date:.*|date:|' > log.out
+  $ hg log -r 'wdir()' -v --style default | sed 's|^date:.*|date:|' > style.out
+  $ cmp log.out style.out || diff -u log.out style.out
+
+  $ hg log -r 'wdir()' -q > log.out
+  $ hg log -r 'wdir()' -q --style default > style.out
+  $ cmp log.out style.out || diff -u log.out style.out
+
+  $ hg log -r 'wdir()' --debug | sed 's|^date:.*|date:|' > log.out
+  $ hg log -r 'wdir()' --debug --style default \
+  > | sed 's|^date:.*|date:|' > style.out
+  $ cmp log.out style.out || diff -u log.out style.out
+
 Default style should also preserve color information (issue2866):
 
   $ cp $HGRCPATH $HGRCPATH-bak