log: fix status template to list copy source per dest (issue5155) stable
authorYuya Nishihara <yuya@tcha.org>
Thu, 24 Mar 2016 22:55:56 +0900
branchstable
changeset 29000 2d3837a4bded
parent 28999 790c076cd4a2
child 29001 923fa9e06ea0
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.
mercurial/templates/map-cmdline.status
tests/test-status.t
--- a/mercurial/templates/map-cmdline.status	Wed Apr 20 16:33:13 2016 +0100
+++ b/mercurial/templates/map-cmdline.status	Thu Mar 24 22:55:56 2016 +0900
@@ -8,18 +8,13 @@
 # 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')}"}'
--- a/tests/test-status.t	Wed Apr 20 16:33:13 2016 +0100
+++ b/tests/test-status.t	Thu Mar 24 22:55:56 2016 +0900
@@ -513,6 +513,18 @@
   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 @@
   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 ..