revlog: deprecate the _nodecache attribute (API)
authorPierre-Yves David <pierre-yves.david@octobus.net>
Sat, 02 Nov 2019 15:46:47 +0100
changeset 43530 6e3e3e5446ba
parent 43529 bf176127033a
child 43531 dcf9826c8d8c
revlog: deprecate the _nodecache attribute (API) This attribute have been the same object for a long time. Code should directly access the nodemap in case of need. (Or the final API when this will be done). This work is part of a refactoring to unify the revlog index and the nodemap. This unification prepare the use of a persistent nodemap. Differential Revision: https://phab.mercurial-scm.org/D7318
mercurial/revlog.py
--- a/mercurial/revlog.py	Sat Nov 02 15:25:31 2019 +0100
+++ b/mercurial/revlog.py	Sat Nov 02 15:46:47 2019 +0100
@@ -388,7 +388,6 @@
         # Mapping of partial identifiers to full nodes.
         self._pcache = {}
         # Mapping of revision integer to full node.
-        self._nodecache = None
         self._nodepos = None
         self._compengine = b'zlib'
         self._compengineopts = {}
@@ -553,7 +552,7 @@
                 _(b"index %s is corrupted") % self.indexfile
             )
         self.index, self._chunkcache = d
-        self.nodemap = self._nodecache = self.index.nodemap
+        self.nodemap = self.index.nodemap
         if not self._chunkcache:
             self._chunkclear()
         # revnum -> (chain-length, sum-delta-length)
@@ -632,6 +631,12 @@
             self.rev(node0)
         return self.index.nodemap
 
+    @property
+    def _nodecache(self):
+        msg = "revlog._nodecache is deprecated, use revlog.index.nodemap"
+        util.nouideprecwarn(msg, b'5.3', stacklevel=2)
+        return self.index.nodemap
+
     def hasnode(self, node):
         try:
             self.rev(node)