Patchwork D7319: revlog: move nodemap update within the index code

login
register
mail settings
Submitter phabricator
Date Nov. 8, 2019, 9:31 a.m.
Message ID <differential-rev-PHID-DREV-s5ttunimvuvd7uylzehy-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/42917/
State Superseded
Headers show

Comments

phabricator - Nov. 8, 2019, 9:31 a.m.
marmoute created this revision.
Herald added a reviewer: indygreg.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Since the nodemap data now live in the index, it should be the index
  responsibility to ensure the data are up to date.
  
  This work is part of a refactoring to unify the revlog index and the nodemap.
  This unification prepare the use of a persistent nodemap.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/pure/parsers.py
  mercurial/revlog.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -213,6 +213,10 @@ 
             nodemap[n] = r
         return nodemap
 
+    def append(self, tup):
+        self.nodemap[tup[7]] = len(self)
+        super(revlogoldindex, self).append(tup)
+
     def clearcaches(self):
         self.__dict__.pop('nodemap', None)
 
@@ -2189,7 +2193,6 @@ 
             node,
         )
         self.index.append(e)
-        self.nodemap[node] = curr
 
         # Reset the pure node cache start lookup offset to account for new
         # revision.
diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py
--- a/mercurial/pure/parsers.py
+++ b/mercurial/pure/parsers.py
@@ -62,6 +62,8 @@ 
         return self._lgt + len(self._extra)
 
     def append(self, tup):
+        if 'nodemap' in vars(self):
+            self.nodemap[tup[7]] = len(self)
         self._extra.append(tup)
 
     def _check_index(self, i):