diff mercurial/revlog.py @ 47164:8d3c2f9d4af7

revlog: use a "radix" to address revlog Instead of pointing to the index directly and to derive the other file from that, we directly provide the radix and let the revlog determine the associated file path internally. This is more robust and will give us more flexibility for picking this file name in the future. Differential Revision: https://phab.mercurial-scm.org/D10576
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 03 May 2021 12:22:36 +0200
parents 396442cd7e6a
children 24be247a13b4
line wrap: on
line diff
--- a/mercurial/revlog.py	Mon May 03 12:22:26 2021 +0200
+++ b/mercurial/revlog.py	Mon May 03 12:22:36 2021 +0200
@@ -289,9 +289,8 @@
         self,
         opener,
         target,
+        radix,
         postfix=None,
-        indexfile=None,
-        datafile=None,
         checkambig=False,
         mmaplargeindex=False,
         censorable=False,
@@ -313,16 +312,19 @@
         accurate value.
         """
         self.upperboundcomp = upperboundcomp
-        if not indexfile.endswith(b'.i'):
-            raise error.ProgrammingError(
-                b"revlog's indexfile should end with `.i`"
-            )
-        if datafile is None:
-            datafile = indexfile[:-2] + b".d"
-            if postfix is not None:
-                datafile = b'%s.%s' % (datafile, postfix)
-        if postfix is not None:
-            indexfile = b'%s.%s' % (indexfile, postfix)
+
+        self.radix = radix
+
+        if postfix is None:
+            indexfile = b'%s.i' % self.radix
+            datafile = b'%s.d' % self.radix
+        elif postfix == b'a':
+            indexfile = b'%s.i.a' % self.radix
+            datafile = b'%s.d' % self.radix
+        else:
+            indexfile = b'%s.i.%s' % (self.radix, postfix)
+            datafile = b'%s.d.%s' % (self.radix, postfix)
+
         self._indexfile = indexfile
         self._datafile = datafile
         self.nodemap_file = None
@@ -2900,8 +2902,8 @@
         newrl = revlog(
             self.opener,
             target=self.target,
+            radix=self.radix,
             postfix=b'tmpcensored',
-            indexfile=self._indexfile,
             censorable=True,
         )
         newrl._format_version = self._format_version