[Updated] D10630: revlog: move the `trypending` logic from the `changelog` to the `revlog`

marmoute (Pierre-Yves David) phabricator at mercurial-scm.org
Mon May 17 21:54:00 UTC 2021


Closed by commit rHG4f38ada3fc26: revlog: move the `trypending` logic from the `changelog` to the `revlog` (authored by marmoute).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D10630?vs=27876&id=28030

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D10630/new/

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

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

CHANGE DETAILS

diff --git a/mercurial/revlogutils/nodemap.py b/mercurial/revlogutils/nodemap.py
--- a/mercurial/revlogutils/nodemap.py
+++ b/mercurial/revlogutils/nodemap.py
@@ -649,7 +649,7 @@
 
 
 def get_nodemap_file(revlog):
-    if revlog.postfix == b'a':
+    if revlog._trypending:
         pending_path = revlog.radix + b".n.a"
         if revlog.opener.exists(pending_path):
             return pending_path
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -293,13 +293,14 @@
         opener,
         target,
         radix,
-        postfix=None,
+        postfix=None,  # only exist for `tmpcensored` now
         checkambig=False,
         mmaplargeindex=False,
         censorable=False,
         upperboundcomp=None,
         persistentnodemap=False,
         concurrencychecker=None,
+        trypending=False,
     ):
         """
         create a revlog object
@@ -323,6 +324,7 @@
         self._datafile = None
         self._nodemap_file = None
         self.postfix = postfix
+        self._trypending = trypending
         self.opener = opener
         if persistentnodemap:
             self._nodemap_file = nodemaputil.get_nodemap_file(self)
@@ -484,10 +486,12 @@
 
         new_header, mmapindexthreshold, force_nodemap = self._init_opts()
 
-        if self.postfix is None:
+        if self.postfix is not None:
+            entry_point = b'%s.i.%s' % (self.radix, self.postfix)
+        elif self._trypending and self.opener.exists(b'%s.i.a' % self.radix):
+            entry_point = b'%s.i.a' % self.radix
+        else:
             entry_point = b'%s.i' % self.radix
-        else:
-            entry_point = b'%s.i.%s' % (self.radix, self.postfix)
 
         entry_data = b''
         self._initempty = True
@@ -545,7 +549,7 @@
             # main docket, so disable it for now.
             self._nodemap_file = None
 
-        if self.postfix is None or self.postfix == b'a':
+        if self.postfix is None:
             self._datafile = b'%s.d' % self.radix
         else:
             self._datafile = b'%s.d.%s' % (self.radix, self.postfix)
@@ -2067,6 +2071,10 @@
 
     @contextlib.contextmanager
     def _writing(self, transaction):
+        if self._trypending:
+            msg = b'try to write in a `trypending` revlog: %s'
+            msg %= self.display_id
+            raise error.ProgrammingError(msg)
         if self._writinghandles is not None:
             yield
         else:
diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -396,21 +396,16 @@
         the documentation there.
         """
 
-        if trypending and opener.exists(b'00changelog.i.a'):
-            postfix = b'a'
-        else:
-            postfix = None
-
         revlog.revlog.__init__(
             self,
             opener,
             target=(revlog_constants.KIND_CHANGELOG, None),
             radix=b'00changelog',
-            postfix=postfix,
             checkambig=True,
             mmaplargeindex=True,
             persistentnodemap=opener.options.get(b'persistent-nodemap', False),
             concurrencychecker=concurrencychecker,
+            trypending=trypending,
         )
 
         if self._initempty and (self._format_version == revlog.REVLOGV1):



To: marmoute, indygreg, #hg-reviewers, Alphare
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210517/3f58089b/attachment-0002.html>


More information about the Mercurial-patches mailing list