changeset 44034:ab595920de0e

revlogutils: move the NodeMap class in a dedicated nodemap module We will introduce more nodemap related code, so it make sense to move the existing code in that module first. Differential Revision: https://phab.mercurial-scm.org/D7809
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 07 Jan 2020 12:26:37 +0100
parents 2d4cad94d08a
children 8ed8dfbeabb9
files mercurial/pure/parsers.py mercurial/revlog.py mercurial/revlogutils/__init__.py mercurial/revlogutils/nodemap.py
diffstat 4 files changed, 21 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/pure/parsers.py	Sun Dec 29 21:10:04 2019 -0500
+++ b/mercurial/pure/parsers.py	Tue Jan 07 12:26:37 2020 +0100
@@ -13,10 +13,11 @@
 from ..node import nullid, nullrev
 from .. import (
     pycompat,
-    revlogutils,
     util,
 )
 
+from ..revlogutils import nodemap as nodemaputil
+
 stringio = pycompat.bytesio
 
 
@@ -55,7 +56,7 @@
 
     @util.propertycache
     def _nodemap(self):
-        nodemap = revlogutils.NodeMap({nullid: nullrev})
+        nodemap = nodemaputil.NodeMap({nullid: nullrev})
         for r in range(0, len(self)):
             n = self[r][7]
             nodemap[n] = r
--- a/mercurial/revlog.py	Sun Dec 29 21:10:04 2019 -0500
+++ b/mercurial/revlog.py	Tue Jan 07 12:26:37 2020 +0100
@@ -65,7 +65,6 @@
     mdiff,
     policy,
     pycompat,
-    revlogutils,
     templatefilters,
     util,
 )
@@ -76,6 +75,7 @@
 from .revlogutils import (
     deltas as deltautil,
     flagutil,
+    nodemap as nodemaputil,
     sidedata as sidedatautil,
 )
 from .utils import (
@@ -224,7 +224,7 @@
 
     @util.propertycache
     def _nodemap(self):
-        nodemap = revlogutils.NodeMap({nullid: nullrev})
+        nodemap = nodemaputil.NodeMap({nullid: nullrev})
         for r in range(0, len(self)):
             n = self[r][7]
             nodemap[n] = r
@@ -273,7 +273,7 @@
     def parseindex(self, data, inline):
         s = self.size
         index = []
-        nodemap = revlogutils.NodeMap({nullid: nullrev})
+        nodemap = nodemaputil.NodeMap({nullid: nullrev})
         n = off = 0
         l = len(data)
         while off + s <= l:
--- a/mercurial/revlogutils/__init__.py	Sun Dec 29 21:10:04 2019 -0500
+++ b/mercurial/revlogutils/__init__.py	Tue Jan 07 12:26:37 2020 +0100
@@ -6,9 +6,3 @@
 # GNU General Public License version 2 or any later version.
 
 from __future__ import absolute_import
-from .. import error
-
-
-class NodeMap(dict):
-    def __missing__(self, x):
-        raise error.RevlogError(b'unknown node: %s' % x)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/revlogutils/nodemap.py	Tue Jan 07 12:26:37 2020 +0100
@@ -0,0 +1,15 @@
+# nodemap.py - nodemap related code and utilities
+#
+# Copyright 2019 Pierre-Yves David <pierre-yves.david@octobus.net>
+# Copyright 2019 George Racinet <georges.racinet@octobus.net>
+#
+# This software may be used and distributed according to the terms of the
+# GNU General Public License version 2 or any later version.
+
+from __future__ import absolute_import
+from .. import error
+
+
+class NodeMap(dict):
+    def __missing__(self, x):
+        raise error.RevlogError(b'unknown node: %s' % x)