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

login
register
mail settings
Submitter phabricator
Date Jan. 7, 2020, 12:52 p.m.
Message ID <differential-rev-PHID-DREV-fyf5443nmtyszvstmk5o-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/44172/
State Superseded
Headers show

Comments

phabricator - Jan. 7, 2020, 12:52 p.m.
marmoute created this revision.
Herald added a reviewer: indygreg.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  We will introduce more nodemap related code, so it make sense to move the
  existing code in that module first.

REPOSITORY
  rHG Mercurial

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
phabricator - Jan. 9, 2020, 5:41 p.m.
martinvonz added a comment.


  We recently gained a `mercurial.utils` module. Should `mercurial.revlogutils` become `mercurial.utils.revlogutil` instead?

REPOSITORY
  rHG Mercurial

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

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

To: marmoute, indygreg, #hg-reviewers
Cc: martinvonz, mercurial-devel
phabricator - Jan. 9, 2020, 6:03 p.m.
marmoute added a comment.


  `utils` is older than `revlogutils`, `revlogutils` focus on revlog related changes and his worth keeping at this.

REPOSITORY
  rHG Mercurial

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

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

To: marmoute, indygreg, #hg-reviewers
Cc: martinvonz, 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 (
@@ -223,7 +223,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
@@ -272,7 +272,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