Show More
@@ -462,8 +462,12 b' def resolvehexnodeidprefix(repo, prefix)' | |||
|
462 | 462 | repo.changelog.rev(node) # make sure node isn't filtered |
|
463 | 463 | return node |
|
464 | 464 | |
|
465 | def shortesthexnodeidprefix(repo, node, minlength=1): | |
|
466 |
"""Find the shortest unambiguous prefix that matches hexnode. |
|
|
465 | def shortesthexnodeidprefix(repo, node, minlength=1, cache=None): | |
|
466 | """Find the shortest unambiguous prefix that matches hexnode. | |
|
467 | ||
|
468 | If "cache" is not None, it must be a dictionary that can be used for | |
|
469 | caching between calls to this method. | |
|
470 | """ | |
|
467 | 471 | # _partialmatch() of filtered changelog could take O(len(repo)) time, |
|
468 | 472 | # which would be unacceptably slow. so we look for hash collision in |
|
469 | 473 | # unfiltered space, which means some hashes may be slightly longer. |
@@ -491,7 +495,13 b' def shortesthexnodeidprefix(repo, node, ' | |||
|
491 | 495 | |
|
492 | 496 | revset = repo.ui.config('experimental', 'revisions.disambiguatewithin') |
|
493 | 497 | if revset: |
|
498 | revs = None | |
|
499 | if cache is not None: | |
|
500 | revs = cache.get('disambiguationrevset') | |
|
501 | if revs is None: | |
|
494 | 502 | revs = repo.anyrevs([revset], user=True) |
|
503 | if cache is not None: | |
|
504 | cache['disambiguationrevset'] = revs | |
|
495 | 505 | if cl.rev(node) in revs: |
|
496 | 506 | hexnode = hex(node) |
|
497 | 507 | for length in range(minlength, len(hexnode) + 1): |
@@ -596,7 +596,7 b' def separate(context, mapping, args):' | |||
|
596 | 596 | yield sep |
|
597 | 597 | yield argstr |
|
598 | 598 | |
|
599 | @templatefunc('shortest(node, minlength=4)', requires={'repo'}) | |
|
599 | @templatefunc('shortest(node, minlength=4)', requires={'repo', 'cache'}) | |
|
600 | 600 | def shortest(context, mapping, args): |
|
601 | 601 | """Obtain the shortest representation of |
|
602 | 602 | a node.""" |
@@ -629,8 +629,9 b' def shortest(context, mapping, args):' | |||
|
629 | 629 | return hexnode |
|
630 | 630 | if not node: |
|
631 | 631 | return hexnode |
|
632 | cache = context.resource(mapping, 'cache') | |
|
632 | 633 | try: |
|
633 | return scmutil.shortesthexnodeidprefix(repo, node, minlength) | |
|
634 | return scmutil.shortesthexnodeidprefix(repo, node, minlength, cache) | |
|
634 | 635 | except error.RepoLookupError: |
|
635 | 636 | return hexnode |
|
636 | 637 |
General Comments 0
You need to be logged in to leave comments.
Login now