changeset 50520:85c5b4b507af

store: use StoreEntry API instead of parsing filename when fixing issue6528 This is more explicit and more robust. We also introduce a small output change as it make things simpler and this is a affecting a debug-command.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 15 May 2023 09:00:28 +0200
parents 5805b8b25426
children 92611344aec2
files mercurial/revlogutils/rewrite.py tests/test-issue6528.t
diffstat 2 files changed, 27 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlogutils/rewrite.py	Mon May 15 09:00:13 2023 +0200
+++ b/mercurial/revlogutils/rewrite.py	Mon May 15 09:00:28 2023 +0200
@@ -828,8 +828,8 @@
             entry
             for entry in repo.store.datafiles()
             if (
-                entry.unencoded_path.endswith(b'.i')
-                and entry.is_revlog
+                entry.is_revlog
+                and entry.is_revlog_main
                 and entry.revlog_type == store.FILEFLAGS_FILELOG
             )
         )
@@ -842,10 +842,9 @@
         found_nothing = True
 
         for entry in files:
-            path = entry.unencoded_path
             progress.increment()
-            filename = _get_filename_from_filelog_index(path)
-            fl = _filelog_from_filename(repo, filename)
+            filename = entry.target_id
+            fl = _filelog_from_filename(repo, entry.target_id)
 
             # Set of filerevs (or hex filenodes if `to_report`) that need fixing
             to_fix = set()
@@ -861,8 +860,8 @@
                         node = binascii.hexlify(fl.node(filerev))
                         raise error.Abort(msg % (filename, node))
                 if affected:
-                    msg = b"found affected revision %d for filelog '%s'\n"
-                    ui.warn(msg % (filerev, path))
+                    msg = b"found affected revision %d for file '%s'\n"
+                    ui.warn(msg % (filerev, filename))
                     found_nothing = False
                     if not dry_run:
                         if to_report:
--- a/tests/test-issue6528.t	Mon May 15 09:00:13 2023 +0200
+++ b/tests/test-issue6528.t	Mon May 15 09:00:28 2023 +0200
@@ -201,9 +201,9 @@
 
 Dry-run the fix
   $ hg debug-repair-issue6528 --dry-run
-  found affected revision 1 for filelog 'data/D.txt.i'
-  found affected revision 1 for filelog 'data/b.txt.i'
-  found affected revision 3 for filelog 'data/b.txt.i'
+  found affected revision 1 for file 'D.txt'
+  found affected revision 1 for file 'b.txt'
+  found affected revision 3 for file 'b.txt'
   $ hg st
   M D.txt
   M b.txt
@@ -220,9 +220,9 @@
 
 Test the --paranoid option
   $ hg debug-repair-issue6528 --dry-run --paranoid
-  found affected revision 1 for filelog 'data/D.txt.i'
-  found affected revision 1 for filelog 'data/b.txt.i'
-  found affected revision 3 for filelog 'data/b.txt.i'
+  found affected revision 1 for file 'D.txt'
+  found affected revision 1 for file 'b.txt'
+  found affected revision 3 for file 'b.txt'
   $ hg st
   M D.txt
   M b.txt
@@ -239,10 +239,10 @@
 
 Run the fix
   $ hg debug-repair-issue6528
-  found affected revision 1 for filelog 'data/D.txt.i'
+  found affected revision 1 for file 'D.txt'
   repaired revision 1 of 'filelog data/D.txt.i'
-  found affected revision 1 for filelog 'data/b.txt.i'
-  found affected revision 3 for filelog 'data/b.txt.i'
+  found affected revision 1 for file 'b.txt'
+  found affected revision 3 for file 'b.txt'
   repaired revision 1 of 'filelog data/b.txt.i'
   repaired revision 3 of 'filelog data/b.txt.i'
 
@@ -281,9 +281,9 @@
   $ tar -xf - < "$TESTDIR"/bundles/issue6528.tar
 
   $ hg debug-repair-issue6528 --to-report $TESTTMP/report.txt
-  found affected revision 1 for filelog 'data/D.txt.i'
-  found affected revision 1 for filelog 'data/b.txt.i'
-  found affected revision 3 for filelog 'data/b.txt.i'
+  found affected revision 1 for file 'D.txt'
+  found affected revision 1 for file 'b.txt'
+  found affected revision 3 for file 'b.txt'
   $ cat $TESTTMP/report.txt
   2a80419dfc31d7dfb308ac40f3f138282de7d73b D.txt
   a58b36ad6b6545195952793099613c2116f3563b,ea4f2f2463cca5b29ddf3461012b8ce5c6dac175 b.txt
@@ -392,10 +392,10 @@
 
 Run the fix on the non-inline revlog
   $ hg debug-repair-issue6528
-  found affected revision 1 for filelog 'data/D.txt.i'
+  found affected revision 1 for file 'D.txt'
   repaired revision 1 of 'filelog data/D.txt.i'
-  found affected revision 1 for filelog 'data/b.txt.i'
-  found affected revision 3 for filelog 'data/b.txt.i'
+  found affected revision 1 for file 'b.txt'
+  found affected revision 3 for file 'b.txt'
   repaired revision 1 of 'filelog data/b.txt.i'
   repaired revision 3 of 'filelog data/b.txt.i'
 
@@ -556,9 +556,9 @@
 And that the repair command find issue to fix.
 
   $ hg debug-repair-issue6528 --dry-run
-  found affected revision 1 for filelog 'data/D.txt.i'
-  found affected revision 1 for filelog 'data/b.txt.i'
-  found affected revision 3 for filelog 'data/b.txt.i'
+  found affected revision 1 for file 'D.txt'
+  found affected revision 1 for file 'b.txt'
+  found affected revision 3 for file 'b.txt'
 
   $ cd ..
 
@@ -604,8 +604,8 @@
 And that the repair command find issue to fix.
 
   $ hg debug-repair-issue6528 --dry-run
-  found affected revision 1 for filelog 'data/D.txt.i'
-  found affected revision 1 for filelog 'data/b.txt.i'
-  found affected revision 3 for filelog 'data/b.txt.i'
+  found affected revision 1 for file 'D.txt'
+  found affected revision 1 for file 'b.txt'
+  found affected revision 3 for file 'b.txt'
 
   $ cd ..