Mercurial > public > mercurial-scm > hg-stable
diff mercurial/templater.py @ 30231:741e5d7f282d stable
templater: do not use index.partialmatch() directly to calculate shortest()
cl.index.partialmatch() isn't a drop-in replacement for cl._partialmatch().
It has no knowledge about hidden revisions, and it raises ValueError if a node
shorter than 4 chars is given. Instead, use index.partialmatch() through
cl._partialmatch(), which has no such problems and gives the identical result
with/without --pure.
The test output was sampled with --pure without this patch, which shows the
most correct result. However, we'll need to switch to using an unfiltered
changelog because _partialmatch() of a filtered changelog can be an order of
magnitude slower.
(with hidden revisions)
% hg log -R hg-committed -r0:20000 -T '{node|shortest}\n' --time > /dev/null
(.^) time: real 1.530 secs (user 1.480+0.000 sys 0.040+0.000)
(.) time: real 43.080 secs (user 43.060+0.000 sys 0.030+0.000)
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 23 Oct 2016 14:05:23 +0900 |
parents | 1c01fa29630f |
children | 362740e05460 |
line wrap: on
line diff
--- a/mercurial/templater.py Wed Oct 26 22:50:06 2016 +0900 +++ b/mercurial/templater.py Sun Oct 23 14:05:23 2016 +0900 @@ -840,13 +840,8 @@ cl = mapping['ctx']._repo.changelog def isvalid(test): try: - try: - cl.index.partialmatch(test) - except AttributeError: - # Pure mercurial doesn't support partialmatch on the index. - # Fallback to the slow way. - if cl._partialmatch(test) is None: - return False + if cl._partialmatch(test) is None: + return False try: i = int(test)