Patchwork D12093: persistent-nodemap: properly delete all nodemap files on downgrade

login
register
mail settings
Submitter phabricator
Date Jan. 27, 2022, 11:25 p.m.
Message ID <differential-rev-PHID-DREV-tspnhxjnov5k7y3h2at5-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50419/
State New
Headers show

Comments

phabricator - Jan. 27, 2022, 11:25 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Previously, we were only deleting the docket fileā€¦

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12093

AFFECTED FILES
  mercurial/revlogutils/nodemap.py
  tests/test-persistent-nodemap.t

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/test-persistent-nodemap.t b/tests/test-persistent-nodemap.t
--- a/tests/test-persistent-nodemap.t
+++ b/tests/test-persistent-nodemap.t
@@ -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
diff --git a/mercurial/revlogutils/nodemap.py b/mercurial/revlogutils/nodemap.py
--- a/mercurial/revlogutils/nodemap.py
+++ b/mercurial/revlogutils/nodemap.py
@@ -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):