Patchwork D7809: revlogutils: move the NodeMap class in a dedicated nodemap module

login
register
mail settings
Submitter phabricator
Date Jan. 8, 2020, 8:04 p.m.
Message ID <2aad24120374c6e68eacedd4e0876df9@localhost.localdomain>
Download mbox | patch
Permalink /patch/44214/
State Not Applicable
Headers show

Comments

phabricator - Jan. 8, 2020, 8:04 p.m.
Closed by commit rHGab595920de0e: revlogutils: move the NodeMap class in a dedicated nodemap module (authored by marmoute).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7809?vs=19061&id=19108

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

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

AFFECTED FILES
  mercurial/pure/parsers.py
  mercurial/revlog.py
  mercurial/revlogutils/__init__.py
  mercurial/revlogutils/nodemap.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/revlogutils/nodemap.py b/mercurial/revlogutils/nodemap.py
new file mode 100644
--- /dev/null
+++ b/mercurial/revlogutils/nodemap.py
@@ -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)
diff --git a/mercurial/revlogutils/__init__.py b/mercurial/revlogutils/__init__.py
--- a/mercurial/revlogutils/__init__.py
+++ b/mercurial/revlogutils/__init__.py
@@ -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)
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -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:
diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py
--- a/mercurial/pure/parsers.py
+++ b/mercurial/pure/parsers.py
@@ -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