Mercurial > public > mercurial-scm > hg-stable
diff mercurial/templatefuncs.py @ 38892:3588e41f796d
shortest: cache disambiguation revset
This makes it actually useful. In compared the time in my hg repo with
69.6k revisions and with a disambiguation revset of "not public()"
that matches 563 visible revisions. I ran "time hg log -T
'{shortest(node1,)}' -r 0:1000" (no revisions within the revset in
that revision range). Before this patch, it took 57s and after it took
0.7s.
Differential Revision: https://phab.mercurial-scm.org/D4039
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 17 Apr 2018 11:16:59 -0700 |
parents | bc8d925342f0 |
children | a2a5d4ad5276 |
line wrap: on
line diff
--- a/mercurial/templatefuncs.py Fri Jul 20 14:36:42 2018 -0700 +++ b/mercurial/templatefuncs.py Tue Apr 17 11:16:59 2018 -0700 @@ -596,7 +596,7 @@ yield sep yield argstr -@templatefunc('shortest(node, minlength=4)', requires={'repo'}) +@templatefunc('shortest(node, minlength=4)', requires={'repo', 'cache'}) def shortest(context, mapping, args): """Obtain the shortest representation of a node.""" @@ -629,8 +629,9 @@ return hexnode if not node: return hexnode + cache = context.resource(mapping, 'cache') try: - return scmutil.shortesthexnodeidprefix(repo, node, minlength) + return scmutil.shortesthexnodeidprefix(repo, node, minlength, cache) except error.RepoLookupError: return hexnode