changeset 48690:d55c4472bbb6

persistent-nodemap: properly delete all nodemap files on downgrade Previously, we were only deleting the docket fileā€¦ Differential Revision: https://phab.mercurial-scm.org/D12093
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 27 Jan 2022 17:04:40 +0100
parents fbf7e383e961
children b4bc9c4f925d
files mercurial/revlogutils/nodemap.py tests/test-persistent-nodemap.t
diffstat 2 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlogutils/nodemap.py	Sat Jan 15 09:08:41 2022 +0300
+++ b/mercurial/revlogutils/nodemap.py	Thu Jan 27 17:04:40 2022 +0100
@@ -144,10 +144,12 @@
 
 def delete_nodemap(tr, repo, revlog):
     """Delete nodemap data on disk for a given revlog"""
-    if revlog._nodemap_file is None:
-        msg = "calling persist nodemap on a revlog without the feature enabled"
-        raise error.ProgrammingError(msg)
-    repo.svfs.tryunlink(revlog._nodemap_file)
+    prefix = revlog.radix
+    pattern = re.compile(br"(^|/)%s(-[0-9a-f]+\.nd|\.n(\.a)?)$" % prefix)
+    dirpath = revlog.opener.dirname(revlog._indexfile)
+    for f in revlog.opener.listdir(dirpath):
+        if pattern.match(f):
+            repo.svfs.tryunlink(f)
 
 
 def persist_nodemap(tr, revlog, pending=False, force=False):
--- a/tests/test-persistent-nodemap.t	Sat Jan 15 09:08:41 2022 +0300
+++ b/tests/test-persistent-nodemap.t	Thu Jan 27 17:04:40 2022 +0100
@@ -809,8 +809,6 @@
     - manifest
   
   $ ls -1 .hg/store/ | egrep '00(changelog|manifest)(\.n|-.*\.nd)'
-  00changelog-*.nd (glob)
-  00manifest-*.nd (glob)
   undo.backup.00changelog.n
   undo.backup.00manifest.n
   $ hg debugnodemap --metadata