Mercurial > hg
comparison mercurial/revlog.py @ 39191:5517d62c1bcc
revlog: fix pure version of _partialmatch() to include nullid
Before this patch, test-issue842.t and a few more tests fail when they
try to refer to the null revision by using a "000.." prefix of it (or
because they use the "shortest" template function which internally
does that).
This should have been part of my a3dacabd476b (index: don't allow
index[len(index)] to mean nullid, 2018-07-20), but I had forgotten to
update another part of the pure code there, so it didn't fail until
a1f934573c0b (parsers: adjust pure-python version to mimic
a3dacabd476b, 2018-08-09) and 65d5de1169dd (revlog: fix pure nodemap
to not access missing index entry, 2018-08-17) fixed the other things
I had missed.
Differential Revision: https://phab.mercurial-scm.org/D4332
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Sat, 18 Aug 2018 23:17:06 -0700 |
parents | a98e926b2f5b |
children | dbc5ead9f40f |
comparison
equal
deleted
inserted
replaced
39190:68b6383a840a | 39191:5517d62c1bcc |
---|---|
25 | 25 |
26 # import stuff from node for others to import from revlog | 26 # import stuff from node for others to import from revlog |
27 from .node import ( | 27 from .node import ( |
28 bin, | 28 bin, |
29 hex, | 29 hex, |
30 nullhex, | |
30 nullid, | 31 nullid, |
31 nullrev, | 32 nullrev, |
32 wdirfilenodeids, | 33 wdirfilenodeids, |
33 wdirhex, | 34 wdirhex, |
34 wdirid, | 35 wdirid, |
1851 l = len(id) // 2 # grab an even number of digits | 1852 l = len(id) // 2 # grab an even number of digits |
1852 prefix = bin(id[:l * 2]) | 1853 prefix = bin(id[:l * 2]) |
1853 nl = [e[7] for e in self.index if e[7].startswith(prefix)] | 1854 nl = [e[7] for e in self.index if e[7].startswith(prefix)] |
1854 nl = [n for n in nl if hex(n).startswith(id) and | 1855 nl = [n for n in nl if hex(n).startswith(id) and |
1855 self.hasnode(n)] | 1856 self.hasnode(n)] |
1857 if nullhex.startswith(id): | |
1858 nl.append(nullid) | |
1856 if len(nl) > 0: | 1859 if len(nl) > 0: |
1857 if len(nl) == 1 and not maybewdir: | 1860 if len(nl) == 1 and not maybewdir: |
1858 self._pcache[id] = nl[0] | 1861 self._pcache[id] = nl[0] |
1859 return nl[0] | 1862 return nl[0] |
1860 raise AmbiguousPrefixLookupError(id, self.indexfile, | 1863 raise AmbiguousPrefixLookupError(id, self.indexfile, |