Patchwork [STABLE] log: fix status template to list copy source per dest (issue5155)

login
register
mail settings
Submitter Yuya Nishihara
Date April 19, 2016, 2:55 p.m.
Message ID <f16bedaa1dd12f09cb5e.1461077743@mimosa>
Download mbox | patch
Permalink /patch/14730/
State Accepted
Delegated to: Augie Fackler
Headers show

Comments

Yuya Nishihara - April 19, 2016, 2:55 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1458827756 -32400
#      Thu Mar 24 22:55:56 2016 +0900
# Branch stable
# Node ID f16bedaa1dd12f09cb5e0dee87d4525d21d5eb6e
# Parent  97811ff7964710d32cae951df1da8019b46151a2
log: fix status template to list copy source per dest (issue5155)

Before, copied files were assumed as "A" (added) and listed followed by
non-copy added files. This could double entries of a copy if it had "M"
(modified) state.

So, this patch makes the template check if a file is included in copies dict.
This way, entries should never be doubled.

The output of "log -Tstatus -C" does not always agree with "status -C --change"
due to the bug of "status", which is documented in test-status.t. See also
2963d5c9d90b.
Augie Fackler - April 22, 2016, 6:09 p.m.
On Tue, Apr 19, 2016 at 11:55:43PM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1458827756 -32400
> #      Thu Mar 24 22:55:56 2016 +0900
> # Branch stable
> # Node ID f16bedaa1dd12f09cb5e0dee87d4525d21d5eb6e
> # Parent  97811ff7964710d32cae951df1da8019b46151a2
> log: fix status template to list copy source per dest (issue5155)
>

queued, thanks

>
> Before, copied files were assumed as "A" (added) and listed followed by
> non-copy added files. This could double entries of a copy if it had "M"
> (modified) state.
>
> So, this patch makes the template check if a file is included in copies dict.
> This way, entries should never be doubled.
>
> The output of "log -Tstatus -C" does not always agree with "status -C --change"
> due to the bug of "status", which is documented in test-status.t. See also
> 2963d5c9d90b.
>
> diff --git a/mercurial/templates/map-cmdline.status b/mercurial/templates/map-cmdline.status
> --- a/mercurial/templates/map-cmdline.status
> +++ b/mercurial/templates/map-cmdline.status
> @@ -8,18 +8,13 @@ changeset_debug = '{fullcset}{branches}{
>  # Override the file templates
>  lfiles = '{if(files,
>                label('ui.note log.files',
> -                    'files:\n'))}{lfile_mods}{lfile_adds}{lfile_copies_switch}{lfile_dels}'
> +                    'files:\n'))}{lfile_mods}{lfile_adds}{lfile_dels}'
>
> -# Exclude copied files, will display those in lfile_copies_switch
> -lfile_adds  = '{file_adds % "{ifcontains(file, file_copies_switch,
> -                                         '',
> -                                         '{lfile_add}')}"}'
> +lfile_adds = '{file_adds % "{lfile_add}{lfile_src}"}'
> +lfile_mods = '{file_mods % "{lfile_mod}{lfile_src}"}'
>  lfile_add = '{label("status.added", "A {file}\n")}'
> -
> -lfile_copies_switch = '{file_copies_switch % "{lfile_copy_orig}{lfile_copy_dest}"}'
> -lfile_copy_orig = '{label("status.added", "A {name}\n")}'
> -lfile_copy_dest = '{label("status.copied", "  {source}\n")}'
> -
> -lfile_mods = '{file_mods % "{label('status.modified', 'M {file}\n')}"}'
> +lfile_mod = '{label("status.modified", "M {file}\n")}'
> +lfile_src = '{ifcontains(file, file_copies_switch,
> +              label("status.copied", "  {get(file_copies_switch, file)}\n"))}'
>
>  lfile_dels = '{file_dels % "{label('status.removed', 'R {file}\n')}"}'
> diff --git a/tests/test-status.t b/tests/test-status.t
> --- a/tests/test-status.t
> +++ b/tests/test-status.t
> @@ -513,6 +513,18 @@ using ui.statuscopies setting
>    M a
>    R b
>
> +using log status template (issue5155)
> +  $ hg log -Tstatus -r 'wdir()' -C
> +  changeset:   2147483647:ffffffffffff
> +  parent:      0:8c55c58b4c0e
> +  user:        test
> +  date:        * (glob)
> +  files:
> +  M a
> +    b
> +  R b
> +
> +
>  Other "bug" highlight, the revision status does not report the copy information.
>  This is buggy behavior.
>
> @@ -521,4 +533,17 @@ This is buggy behavior.
>    M a
>    R b
>
> +using log status template, the copy information is displayed correctly.
> +  $ hg log -Tstatus -r. -C
> +  changeset:   1:6685fde43d21
> +  tag:         tip
> +  user:        test
> +  date:        * (glob)
> +  summary:     blah
> +  files:
> +  M a
> +    b
> +  R b
> +
> +
>    $ cd ..
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/templates/map-cmdline.status b/mercurial/templates/map-cmdline.status
--- a/mercurial/templates/map-cmdline.status
+++ b/mercurial/templates/map-cmdline.status
@@ -8,18 +8,13 @@  changeset_debug = '{fullcset}{branches}{
 # Override the file templates
 lfiles = '{if(files,
               label('ui.note log.files',
-                    'files:\n'))}{lfile_mods}{lfile_adds}{lfile_copies_switch}{lfile_dels}'
+                    'files:\n'))}{lfile_mods}{lfile_adds}{lfile_dels}'
 
-# Exclude copied files, will display those in lfile_copies_switch
-lfile_adds  = '{file_adds % "{ifcontains(file, file_copies_switch,
-                                         '',
-                                         '{lfile_add}')}"}'
+lfile_adds = '{file_adds % "{lfile_add}{lfile_src}"}'
+lfile_mods = '{file_mods % "{lfile_mod}{lfile_src}"}'
 lfile_add = '{label("status.added", "A {file}\n")}'
-
-lfile_copies_switch = '{file_copies_switch % "{lfile_copy_orig}{lfile_copy_dest}"}'
-lfile_copy_orig = '{label("status.added", "A {name}\n")}'
-lfile_copy_dest = '{label("status.copied", "  {source}\n")}'
-
-lfile_mods = '{file_mods % "{label('status.modified', 'M {file}\n')}"}'
+lfile_mod = '{label("status.modified", "M {file}\n")}'
+lfile_src = '{ifcontains(file, file_copies_switch,
+              label("status.copied", "  {get(file_copies_switch, file)}\n"))}'
 
 lfile_dels = '{file_dels % "{label('status.removed', 'R {file}\n')}"}'
diff --git a/tests/test-status.t b/tests/test-status.t
--- a/tests/test-status.t
+++ b/tests/test-status.t
@@ -513,6 +513,18 @@  using ui.statuscopies setting
   M a
   R b
 
+using log status template (issue5155)
+  $ hg log -Tstatus -r 'wdir()' -C
+  changeset:   2147483647:ffffffffffff
+  parent:      0:8c55c58b4c0e
+  user:        test
+  date:        * (glob)
+  files:
+  M a
+    b
+  R b
+  
+
 Other "bug" highlight, the revision status does not report the copy information.
 This is buggy behavior.
 
@@ -521,4 +533,17 @@  This is buggy behavior.
   M a
   R b
 
+using log status template, the copy information is displayed correctly.
+  $ hg log -Tstatus -r. -C
+  changeset:   1:6685fde43d21
+  tag:         tip
+  user:        test
+  date:        * (glob)
+  summary:     blah
+  files:
+  M a
+    b
+  R b
+  
+
   $ cd ..