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/parsers.c (2 lines) | |||
M | mercurial/cext/revlog.c (10 lines) | |||
M | mercurial/policy.py (2 lines) | |||
M | mercurial/pure/parsers.py (4 lines) | |||
M | mercurial/revlog.py (4 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
588a224931ca | 0c3547700fa5 | 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 |
{"fm1readmarkers", fm1readmarkers, METH_VARARGS, | {"fm1readmarkers", fm1readmarkers, METH_VARARGS, | ||||
"parse v1 obsolete markers\n"}, | "parse v1 obsolete markers\n"}, | ||||
{NULL, NULL}}; | {NULL, NULL}}; | ||||
void dirs_module_init(PyObject *mod); | void dirs_module_init(PyObject *mod); | ||||
void manifest_module_init(PyObject *mod); | void manifest_module_init(PyObject *mod); | ||||
void revlog_module_init(PyObject *mod); | void revlog_module_init(PyObject *mod); | ||||
static const int version = 13; | static const int version = 14; | ||||
static void module_init(PyObject *mod) | static void module_init(PyObject *mod) | ||||
{ | { | ||||
PyObject *capsule = NULL; | PyObject *capsule = NULL; | ||||
PyModule_AddIntConstant(mod, "version", version); | PyModule_AddIntConstant(mod, "version", version); | ||||
/* This module constant has two purposes. First, it lets us unit test | /* This module constant has two purposes. First, it lets us unit test | ||||
* the ImportError raised without hard-coding any error text. This | * the ImportError raised without hard-coding any error text. This |
# keep in sync with "version" in C modules | # keep in sync with "version" in C modules | ||||
_cextversions = { | _cextversions = { | ||||
('cext', 'base85'): 1, | ('cext', 'base85'): 1, | ||||
('cext', 'bdiff'): 3, | ('cext', 'bdiff'): 3, | ||||
('cext', 'mpatch'): 1, | ('cext', 'mpatch'): 1, | ||||
('cext', 'osutil'): 4, | ('cext', 'osutil'): 4, | ||||
('cext', 'parsers'): 13, | ('cext', 'parsers'): 14, | ||||
} | } | ||||
# map import request to other package or module | # map import request to other package or module | ||||
_modredirects = { | _modredirects = { | ||||
('cext', 'charencode'): ('cext', 'parsers'), | ('cext', 'charencode'): ('cext', 'parsers'), | ||||
('cffi', 'base85'): ('pure', 'base85'), | ('cffi', 'base85'): ('pure', 'base85'), | ||||
('cffi', 'charencode'): ('pure', 'charencode'), | ('cffi', 'charencode'): ('pure', 'charencode'), | ||||
('cffi', 'parsers'): ('pure', 'parsers'), | ('cffi', 'parsers'): ('pure', 'parsers'), |
@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.