Patchwork D10577: revlog: stop usage of `_indexfile` to computing nodemap path

login
register
mail settings
Submitter phabricator
Date May 3, 2021, 11:59 a.m.
Message ID <differential-rev-PHID-DREV-csq5kbwqmehdqdmbaufz-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48893/
State New
Headers show

Comments

phabricator - May 3, 2021, 11:59 a.m.
marmoute created this revision.
Herald added a reviewer: indygreg.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We now have the radix explicitely lets use the radix explicitely

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/revlog.py
  mercurial/revlogutils/nodemap.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/revlogutils/nodemap.py b/mercurial/revlogutils/nodemap.py
--- a/mercurial/revlogutils/nodemap.py
+++ b/mercurial/revlogutils/nodemap.py
@@ -148,9 +148,7 @@ 
         )
     if revlog.nodemap_file is None:
         if force:
-            revlog.nodemap_file = get_nodemap_file(
-                revlog.opener, revlog._indexfile
-            )
+            revlog.nodemap_file = get_nodemap_file(revlog)
         else:
             msg = "calling persist nodemap on a revlog without the feature enabled"
             raise error.ProgrammingError(msg)
@@ -653,12 +651,9 @@ 
     return entry
 
 
-def get_nodemap_file(opener, indexfile):
-    if indexfile.endswith(b'.a'):
-        pending_path = indexfile[:-4] + b".n.a"
-        if opener.exists(pending_path):
+def get_nodemap_file(revlog):
+    if revlog.postfix == b'a':
+        pending_path = revlog.radix + b".n.a"
+        if revlog.opener.exists(pending_path):
             return pending_path
-        else:
-            return indexfile[:-4] + b".n"
-    else:
-        return indexfile[:-2] + b".n"
+    return revlog.radix + b".n"
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -329,12 +329,10 @@ 
         self._datafile = datafile
         self.nodemap_file = None
         self.postfix = postfix
+        self.opener = opener
         if persistentnodemap:
-            self.nodemap_file = nodemaputil.get_nodemap_file(
-                opener, self._indexfile
-            )
-
-        self.opener = opener
+            self.nodemap_file = nodemaputil.get_nodemap_file(self)
+
         assert target[0] in ALL_KINDS
         assert len(target) == 2
         self.target = target