Now that all in-core user have been updated to the new API, we can deprecated
direct access to nodemap.
Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
Now that all in-core user have been updated to the new API, we can deprecated
direct access to nodemap.
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/pure/parsers.py (24 lines) | |||
M | mercurial/revlog.py (28 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
2f28204c5d11 | c0f8e33b0b02 | Pierre-Yves David | Nov 8 2019, 9:40 AM |
Status | Author | Revision | |
---|---|---|---|
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute |
return int(q & 0xFFFF) | return int(q & 0xFFFF) | ||||
def offset_type(offset, type): | def offset_type(offset, type): | ||||
return int(int(offset) << 16 | type) | return int(int(offset) << 16 | type) | ||||
class BaseIndexObject(object): | class BaseIndexObject(object): | ||||
@util.propertycache | @property | ||||
def nodemap(self): | def nodemap(self): | ||||
msg = "index.nodemap is deprecated, " "use index.[has_node|rev|get_rev]" | |||||
util.nouideprecwarn(msg, b'5.3', stacklevel=2) | |||||
return self._nodemap | |||||
@util.propertycache | |||||
def _nodemap(self): | |||||
nodemap = revlogutils.NodeMap({nullid: nullrev}) | nodemap = revlogutils.NodeMap({nullid: nullrev}) | ||||
for r in range(0, len(self)): | for r in range(0, len(self)): | ||||
n = self[r][7] | n = self[r][7] | ||||
nodemap[n] = r | nodemap[n] = r | ||||
return nodemap | return nodemap | ||||
def has_node(self, node): | def has_node(self, node): | ||||
"""return True if the node exist in the index""" | """return True if the node exist in the index""" | ||||
return node in self.nodemap | return node in self._nodemap | ||||
def rev(self, node): | def rev(self, node): | ||||
"""return a revision for a node | """return a revision for a node | ||||
If the node is unknown, raise a RevlogError""" | If the node is unknown, raise a RevlogError""" | ||||
return self.nodemap[node] | return self._nodemap[node] | ||||
def get_rev(self, node): | def get_rev(self, node): | ||||
"""return a revision for a node | """return a revision for a node | ||||
If the node is unknown, return None""" | If the node is unknown, return None""" | ||||
return self.nodemap.get(node) | return self._nodemap.get(node) | ||||
def _stripnodes(self, start): | def _stripnodes(self, start): | ||||
if 'nodemap' in vars(self): | if '_nodemap' in vars(self): | ||||
for r in range(start, len(self)): | for r in range(start, len(self)): | ||||
n = self[r][7] | n = self[r][7] | ||||
del self.nodemap[n] | del self._nodemap[n] | ||||
def clearcaches(self): | def clearcaches(self): | ||||
self.__dict__.pop('nodemap', None) | self.__dict__.pop('_nodemap', None) | ||||
def __len__(self): | def __len__(self): | ||||
return self._lgt + len(self._extra) | return self._lgt + len(self._extra) | ||||
def append(self, tup): | def append(self, tup): | ||||
if 'nodemap' in vars(self): | if '_nodemap' in vars(self): | ||||
self.nodemap[tup[7]] = len(self) | self._nodemap[tup[7]] = len(self) | ||||
self._extra.append(tup) | self._extra.append(tup) | ||||
def _check_index(self, i): | def _check_index(self, i): | ||||
if not isinstance(i, int): | if not isinstance(i, int): | ||||
raise TypeError(b"expecting int indexes") | raise TypeError(b"expecting int indexes") | ||||
if i < 0 or i >= len(self): | if i < 0 or i >= len(self): | ||||
raise IndexError | raise IndexError | ||||
# 20 bytes: parent 2 nodeid | # 20 bytes: parent 2 nodeid | ||||
# 20 bytes: nodeid | # 20 bytes: nodeid | ||||
indexformatv0 = struct.Struct(b">4l20s20s20s") | indexformatv0 = struct.Struct(b">4l20s20s20s") | ||||
indexformatv0_pack = indexformatv0.pack | indexformatv0_pack = indexformatv0.pack | ||||
indexformatv0_unpack = indexformatv0.unpack | indexformatv0_unpack = indexformatv0.unpack | ||||
class revlogoldindex(list): | class revlogoldindex(list): | ||||
@util.propertycache | @property | ||||
def nodemap(self): | def nodemap(self): | ||||
msg = "index.nodemap is deprecated, " "use index.[has_node|rev|get_rev]" | |||||
util.nouideprecwarn(msg, b'5.3', stacklevel=2) | |||||
return self._nodemap | |||||
@util.propertycache | |||||
def _nodemap(self): | |||||
nodemap = revlogutils.NodeMap({nullid: nullrev}) | nodemap = revlogutils.NodeMap({nullid: nullrev}) | ||||
for r in range(0, len(self)): | for r in range(0, len(self)): | ||||
n = self[r][7] | n = self[r][7] | ||||
nodemap[n] = r | nodemap[n] = r | ||||
return nodemap | return nodemap | ||||
def has_node(self, node): | def has_node(self, node): | ||||
"""return True if the node exist in the index""" | """return True if the node exist in the index""" | ||||
return node in self.nodemap | return node in self._nodemap | ||||
def rev(self, node): | def rev(self, node): | ||||
"""return a revision for a node | """return a revision for a node | ||||
If the node is unknown, raise a RevlogError""" | If the node is unknown, raise a RevlogError""" | ||||
return self.nodemap[node] | return self._nodemap[node] | ||||
def get_rev(self, node): | def get_rev(self, node): | ||||
"""return a revision for a node | """return a revision for a node | ||||
If the node is unknown, return None""" | If the node is unknown, return None""" | ||||
return self.nodemap.get(node) | return self._nodemap.get(node) | ||||
def append(self, tup): | def append(self, tup): | ||||
self.nodemap[tup[7]] = len(self) | self._nodemap[tup[7]] = len(self) | ||||
super(revlogoldindex, self).append(tup) | super(revlogoldindex, self).append(tup) | ||||
def __delitem__(self, i): | def __delitem__(self, i): | ||||
if not isinstance(i, slice) or not i.stop == -1 or i.step is not None: | if not isinstance(i, slice) or not i.stop == -1 or i.step is not None: | ||||
raise ValueError(b"deleting slices only supports a:-1 with step 1") | raise ValueError(b"deleting slices only supports a:-1 with step 1") | ||||
for r in pycompat.xrange(i.start, len(self)): | for r in pycompat.xrange(i.start, len(self)): | ||||
del self.nodemap[self[r][7]] | del self._nodemap[self[r][7]] | ||||
super(revlogoldindex, self).__delitem__(i) | super(revlogoldindex, self).__delitem__(i) | ||||
def clearcaches(self): | def clearcaches(self): | ||||
self.__dict__.pop('nodemap', None) | self.__dict__.pop('_nodemap', None) | ||||
def __getitem__(self, i): | def __getitem__(self, i): | ||||
if i == -1: | if i == -1: | ||||
return (0, 0, 0, -1, -1, -1, -1, nullid) | return (0, 0, 0, -1, -1, -1, -1, nullid) | ||||
return list.__getitem__(self, i) | return list.__getitem__(self, i) | ||||
class revlogoldio(object): | class revlogoldio(object): | ||||
self._io = revlogoldio() | self._io = revlogoldio() | ||||
try: | try: | ||||
d = self._io.parseindex(indexdata, self._inline) | d = self._io.parseindex(indexdata, self._inline) | ||||
except (ValueError, IndexError): | except (ValueError, IndexError): | ||||
raise error.RevlogError( | raise error.RevlogError( | ||||
_(b"index %s is corrupted") % self.indexfile | _(b"index %s is corrupted") % self.indexfile | ||||
) | ) | ||||
self.index, self._chunkcache = d | self.index, self._chunkcache = d | ||||
self.nodemap = self.index.nodemap | |||||
if not self._chunkcache: | if not self._chunkcache: | ||||
self._chunkclear() | self._chunkclear() | ||||
# revnum -> (chain-length, sum-delta-length) | # revnum -> (chain-length, sum-delta-length) | ||||
self._chaininfocache = {} | self._chaininfocache = {} | ||||
# revlog header -> revlog compressor | # revlog header -> revlog compressor | ||||
self._decompressors = {} | self._decompressors = {} | ||||
@util.propertycache | @util.propertycache | ||||
def __iter__(self): | def __iter__(self): | ||||
return iter(pycompat.xrange(len(self))) | return iter(pycompat.xrange(len(self))) | ||||
def revs(self, start=0, stop=None): | def revs(self, start=0, stop=None): | ||||
"""iterate over all rev in this revlog (from start to stop)""" | """iterate over all rev in this revlog (from start to stop)""" | ||||
return storageutil.iterrevs(len(self), start=start, stop=stop) | return storageutil.iterrevs(len(self), start=start, stop=stop) | ||||
@util.propertycache | @property | ||||
def nodemap(self): | def nodemap(self): | ||||
msg = ( | |||||
"revlog.nodemap is deprecated, " | |||||
"use revlog.index.[has_node|rev|get_rev]" | |||||
) | |||||
util.nouideprecwarn(msg, b'5.3', stacklevel=2) | |||||
return self.index.nodemap | return self.index.nodemap | ||||
@property | @property | ||||
def _nodecache(self): | def _nodecache(self): | ||||
msg = "revlog._nodecache is deprecated, use revlog.index.nodemap" | msg = "revlog._nodecache is deprecated, use revlog.index.nodemap" | ||||
util.nouideprecwarn(msg, b'5.3', stacklevel=2) | util.nouideprecwarn(msg, b'5.3', stacklevel=2) | ||||
return self.index.nodemap | return self.index.nodemap | ||||