Show More
@@ -447,10 +447,8 b' def longestshortest(repo, revs, minlen=4' | |||||
447 | """ |
|
447 | """ | |
448 | if not revs: |
|
448 | if not revs: | |
449 | return minlen |
|
449 | return minlen | |
450 | # don't use filtered repo because it's slow. see templater.shortest(). |
|
|||
451 | cl = repo.changelog |
|
450 | cl = repo.changelog | |
452 |
return max(len(scmutil.shortesthexnodeidprefix(repo. |
|
451 | return max(len(scmutil.shortesthexnodeidprefix(repo, hex(cl.node(r)), | |
453 | hex(cl.node(r)), |
|
|||
454 | minlen)) for r in revs) |
|
452 | minlen)) for r in revs) | |
455 |
|
453 | |||
456 | # Adjust the docstring of the show command so it shows all registered views. |
|
454 | # Adjust the docstring of the show command so it shows all registered views. |
@@ -436,7 +436,7 b' def formatrevnode(ui, rev, node):' | |||||
436 |
|
436 | |||
437 | def resolvehexnodeidprefix(repo, prefix): |
|
437 | def resolvehexnodeidprefix(repo, prefix): | |
438 | # Uses unfiltered repo because it's faster when prefix is ambiguous/ |
|
438 | # Uses unfiltered repo because it's faster when prefix is ambiguous/ | |
439 |
# This matches the |
|
439 | # This matches the shortesthexnodeidprefix() function below. | |
440 | node = repo.unfiltered().changelog._partialmatch(prefix) |
|
440 | node = repo.unfiltered().changelog._partialmatch(prefix) | |
441 | if node is None: |
|
441 | if node is None: | |
442 | return |
|
442 | return | |
@@ -445,7 +445,10 b' def resolvehexnodeidprefix(repo, prefix)' | |||||
445 |
|
445 | |||
446 | def shortesthexnodeidprefix(repo, hexnode, minlength=1): |
|
446 | def shortesthexnodeidprefix(repo, hexnode, minlength=1): | |
447 | """Find the shortest unambiguous prefix that matches hexnode.""" |
|
447 | """Find the shortest unambiguous prefix that matches hexnode.""" | |
448 | return repo.changelog.shortest(hexnode, minlength) |
|
448 | # _partialmatch() of filtered changelog could take O(len(repo)) time, | |
|
449 | # which would be unacceptably slow. so we look for hash collision in | |||
|
450 | # unfiltered space, which means some hashes may be slightly longer. | |||
|
451 | return repo.unfiltered().changelog.shortest(hexnode, minlength) | |||
449 |
|
452 | |||
450 | def isrevsymbol(repo, symbol): |
|
453 | def isrevsymbol(repo, symbol): | |
451 | """Checks if a symbol exists in the repo. |
|
454 | """Checks if a symbol exists in the repo. |
@@ -587,11 +587,8 b' def shortest(context, mapping, args):' | |||||
587 | # i18n: "shortest" is a keyword |
|
587 | # i18n: "shortest" is a keyword | |
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, |
|
|||
591 | # which would be unacceptably slow. so we look for hash collision in |
|
|||
592 | # unfiltered space, which means some hashes may be slightly longer. |
|
|||
593 | repo = context.resource(mapping, 'ctx')._repo |
|
590 | repo = context.resource(mapping, 'ctx')._repo | |
594 |
return scmutil.shortesthexnodeidprefix(repo |
|
591 | return scmutil.shortesthexnodeidprefix(repo, node, minlength) | |
595 |
|
592 | |||
596 | @templatefunc('strip(text[, chars])') |
|
593 | @templatefunc('strip(text[, chars])') | |
597 | def strip(context, mapping, args): |
|
594 | def strip(context, mapping, args): |
General Comments 0
You need to be logged in to leave comments.
Login now