changeset 47165:24be247a13b4

revlog: stop usage of `_indexfile` to computing nodemap path We now have the radix explicitely lets use the radix explicitely Differential Revision: https://phab.mercurial-scm.org/D10577
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 03 May 2021 12:22:47 +0200
parents 8d3c2f9d4af7
children 09338a2d5c14
files mercurial/revlog.py mercurial/revlogutils/nodemap.py
diffstat 2 files changed, 9 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlog.py	Mon May 03 12:22:36 2021 +0200
+++ b/mercurial/revlog.py	Mon May 03 12:22:47 2021 +0200
@@ -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
--- a/mercurial/revlogutils/nodemap.py	Mon May 03 12:22:36 2021 +0200
+++ b/mercurial/revlogutils/nodemap.py	Mon May 03 12:22:47 2021 +0200
@@ -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"