From patchwork Wed Jan 8 20:04:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D7809: revlogutils: move the NodeMap class in a dedicated nodemap module From: phabricator X-Patchwork-Id: 44214 Message-Id: <2aad24120374c6e68eacedd4e0876df9@localhost.localdomain> To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Wed, 8 Jan 2020 20:04:39 +0000 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 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 +# Copyright 2019 George Racinet +# +# 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