Mercurial > hg
comparison mercurial/templatefuncs.py @ 37680:e743b8524d60
scmutil: introduce shortesthexnodeidprefix()
We have scmutil.resolvehexnodeidprefix() for resolving a prefix to a
full nodeid, so it makes sense to have the inverse method next to
it. For now it just delegates to changelog.shortest(), but it will
soon also make sure it's called on the unfiltered repo, to match
resolvehexnodeidprefix().
Note that the change in show.py also makes it so the conversion from
revnum to nodeid is done on the filtered repo, but that should be
inconsequential since the revs are all from the filtered repo anyway.
Differential Revision: https://phab.mercurial-scm.org/D3370
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 13 Apr 2018 22:55:01 -0700 |
parents | f83cb91b052e |
children | 8e8541610d85 |
comparison
equal
deleted
inserted
replaced
37679:ab828755e1ea | 37680:e743b8524d60 |
---|---|
588 _("shortest() expects an integer minlength")) | 588 _("shortest() expects an integer minlength")) |
589 | 589 |
590 # _partialmatch() of filtered changelog could take O(len(repo)) time, | 590 # _partialmatch() of filtered changelog could take O(len(repo)) time, |
591 # which would be unacceptably slow. so we look for hash collision in | 591 # which would be unacceptably slow. so we look for hash collision in |
592 # unfiltered space, which means some hashes may be slightly longer. | 592 # unfiltered space, which means some hashes may be slightly longer. |
593 cl = context.resource(mapping, 'ctx')._repo.unfiltered().changelog | 593 repo = context.resource(mapping, 'ctx')._repo |
594 return cl.shortest(node, minlength) | 594 return scmutil.shortesthexnodeidprefix(repo.unfiltered(), node, minlength) |
595 | 595 |
596 @templatefunc('strip(text[, chars])') | 596 @templatefunc('strip(text[, chars])') |
597 def strip(context, mapping, args): | 597 def strip(context, mapping, args): |
598 """Strip characters from a string. By default, | 598 """Strip characters from a string. By default, |
599 strips all leading and trailing whitespace.""" | 599 strips all leading and trailing whitespace.""" |