changeset 46479:c2435280ca63

copy-tracing: add a --compute flag to debugchangedfiles This will help analysis of possible misbehaving cases. Differential Revision: https://phab.mercurial-scm.org/D9946
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 02 Feb 2021 07:02:25 +0100
parents db9e33beb0fb
children 05dd091dfa6a
files mercurial/debugcommands.py tests/test-completion.t tests/test-copies-chain-merge.t
diffstat 3 files changed, 29 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/debugcommands.py	Wed Feb 03 23:23:56 2021 -0800
+++ b/mercurial/debugcommands.py	Tue Feb 02 07:02:25 2021 +0100
@@ -484,14 +484,31 @@
                 ui.write(b'    %s\n' % v)
 
 
-@command(b'debugchangedfiles', [], b'REV')
-def debugchangedfiles(ui, repo, rev):
+@command(
+    b'debugchangedfiles',
+    [
+        (
+            b'',
+            b'compute',
+            False,
+            b"compute information instead of reading it from storage",
+        ),
+    ],
+    b'REV',
+)
+def debugchangedfiles(ui, repo, rev, **opts):
     """list the stored files changes for a revision"""
     ctx = scmutil.revsingle(repo, rev, None)
-    sd = repo.changelog.sidedata(ctx.rev())
-    files_block = sd.get(sidedata.SD_FILES)
-    if files_block is not None:
-        files = metadata.decode_files_sidedata(sd)
+    files = None
+
+    if opts['compute']:
+        files = metadata.compute_all_files_changes(ctx)
+    else:
+        sd = repo.changelog.sidedata(ctx.rev())
+        files_block = sd.get(sidedata.SD_FILES)
+        if files_block is not None:
+            files = metadata.decode_files_sidedata(sd)
+    if files is not None:
         for f in sorted(files.touched):
             if f in files.added:
                 action = b"added"
--- a/tests/test-completion.t	Wed Feb 03 23:23:56 2021 -0800
+++ b/tests/test-completion.t	Tue Feb 02 07:02:25 2021 +0100
@@ -272,7 +272,7 @@
   debugbuilddag: mergeable-file, overwritten-file, new-file
   debugbundle: all, part-type, spec
   debugcapabilities: 
-  debugchangedfiles: 
+  debugchangedfiles: compute
   debugcheckstate: 
   debugcolor: style
   debugcommands: 
--- a/tests/test-copies-chain-merge.t	Wed Feb 03 23:23:56 2021 -0800
+++ b/tests/test-copies-chain-merge.t	Tue Feb 02 07:02:25 2021 +0100
@@ -721,6 +721,11 @@
 
 #if no-compatibility no-filelog no-changeset
 
+  $ hg debugchangedfiles --compute 0
+  added      : a, ;
+  added      : b, ;
+  added      : h, ;
+
   $ for rev in `hg log --rev 'all()' -T '{rev}\n'`; do
   >     echo "##### revision $rev #####"
   >     hg debugsidedata -c -v -- $rev