The new index.has_node(node) is to be preferred over:
`node in index.nodemap`.
This get us closer to be able to remove the nodemap attribute of the index.
( )
indygreg |
hg-reviewers |
The new index.has_node(node) is to be preferred over:
`node in index.nodemap`.
This get us closer to be able to remove the nodemap attribute of the index.
Lint Skipped |
Unit Tests Skipped |
mercurial/cext/revlog.c | ||
---|---|---|
2071 | Good catch ! updating the patch. |
I think this needs to update the version number in mercurial/cext/parsers.c and in mercurial/policy.py. That will make hg fall back to pure code if it doesn't find the right version of the C code, making updating across this commit easier.
Path | Packages | |||
---|---|---|---|---|
M | mercurial/cext/revlog.c (10 lines) | |||
M | mercurial/pure/parsers.py (4 lines) | |||
M | mercurial/revlog.py (4 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
8f9a78c6ac37 | 858abcff819a | Pierre-Yves David | Nov 2 2019, 7:01 PM |
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 |
@util.propertycache | @util.propertycache | ||||
def nodemap(self): | 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): | |||||
"""return True if the node exist in the index""" | |||||
return node in self.nodemap | |||||
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) |
@util.propertycache | @util.propertycache | ||||
def nodemap(self): | 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): | |||||
"""return True if the node exist in the index""" | |||||
return node in self.nodemap | |||||
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)): |
index_contains() can return -1 in many cases (including invalid input), which will cast to True. So this implementation needs improved.