##// END OF EJS Templates
revlogutils: move the NodeMap class in a dedicated nodemap module...
marmoute -
r44486:ab595920 default
parent child Browse files
Show More
@@ -0,0 +1,15 b''
1 # nodemap.py - nodemap related code and utilities
2 #
3 # Copyright 2019 Pierre-Yves David <pierre-yves.david@octobus.net>
4 # Copyright 2019 George Racinet <georges.racinet@octobus.net>
5 #
6 # This software may be used and distributed according to the terms of the
7 # GNU General Public License version 2 or any later version.
8
9 from __future__ import absolute_import
10 from .. import error
11
12
13 class NodeMap(dict):
14 def __missing__(self, x):
15 raise error.RevlogError(b'unknown node: %s' % x)
@@ -13,10 +13,11 b' import zlib'
13 from ..node import nullid, nullrev
13 from ..node import nullid, nullrev
14 from .. import (
14 from .. import (
15 pycompat,
15 pycompat,
16 revlogutils,
17 util,
16 util,
18 )
17 )
19
18
19 from ..revlogutils import nodemap as nodemaputil
20
20 stringio = pycompat.bytesio
21 stringio = pycompat.bytesio
21
22
22
23
@@ -55,7 +56,7 b' class BaseIndexObject(object):'
55
56
56 @util.propertycache
57 @util.propertycache
57 def _nodemap(self):
58 def _nodemap(self):
58 nodemap = revlogutils.NodeMap({nullid: nullrev})
59 nodemap = nodemaputil.NodeMap({nullid: nullrev})
59 for r in range(0, len(self)):
60 for r in range(0, len(self)):
60 n = self[r][7]
61 n = self[r][7]
61 nodemap[n] = r
62 nodemap[n] = r
@@ -65,7 +65,6 b' from . import ('
65 mdiff,
65 mdiff,
66 policy,
66 policy,
67 pycompat,
67 pycompat,
68 revlogutils,
69 templatefilters,
68 templatefilters,
70 util,
69 util,
71 )
70 )
@@ -76,6 +75,7 b' from .interfaces import ('
76 from .revlogutils import (
75 from .revlogutils import (
77 deltas as deltautil,
76 deltas as deltautil,
78 flagutil,
77 flagutil,
78 nodemap as nodemaputil,
79 sidedata as sidedatautil,
79 sidedata as sidedatautil,
80 )
80 )
81 from .utils import (
81 from .utils import (
@@ -224,7 +224,7 b' class revlogoldindex(list):'
224
224
225 @util.propertycache
225 @util.propertycache
226 def _nodemap(self):
226 def _nodemap(self):
227 nodemap = revlogutils.NodeMap({nullid: nullrev})
227 nodemap = nodemaputil.NodeMap({nullid: nullrev})
228 for r in range(0, len(self)):
228 for r in range(0, len(self)):
229 n = self[r][7]
229 n = self[r][7]
230 nodemap[n] = r
230 nodemap[n] = r
@@ -273,7 +273,7 b' class revlogoldio(object):'
273 def parseindex(self, data, inline):
273 def parseindex(self, data, inline):
274 s = self.size
274 s = self.size
275 index = []
275 index = []
276 nodemap = revlogutils.NodeMap({nullid: nullrev})
276 nodemap = nodemaputil.NodeMap({nullid: nullrev})
277 n = off = 0
277 n = off = 0
278 l = len(data)
278 l = len(data)
279 while off + s <= l:
279 while off + s <= l:
@@ -6,9 +6,3 b''
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 from __future__ import absolute_import
8 from __future__ import absolute_import
9 from .. import error
10
11
12 class NodeMap(dict):
13 def __missing__(self, x):
14 raise error.RevlogError(b'unknown node: %s' % x)
General Comments 0
You need to be logged in to leave comments. Login now