Show More
@@ -1502,18 +1502,6 b' class revlog(object):' | |||||
1502 |
|
1502 | |||
1503 | def shortest(self, node, minlength=1): |
|
1503 | def shortest(self, node, minlength=1): | |
1504 | """Find the shortest unambiguous prefix that matches node.""" |
|
1504 | """Find the shortest unambiguous prefix that matches node.""" | |
1505 | def isrev(prefix): |
|
|||
1506 | try: |
|
|||
1507 | i = int(prefix) |
|
|||
1508 | # if we are a pure int, then starting with zero will not be |
|
|||
1509 | # confused as a rev; or, obviously, if the int is larger |
|
|||
1510 | # than the value of the tip rev |
|
|||
1511 | if prefix[0] == '0' or i > len(self): |
|
|||
1512 | return False |
|
|||
1513 | return True |
|
|||
1514 | except ValueError: |
|
|||
1515 | return False |
|
|||
1516 |
|
||||
1517 | def isvalid(prefix): |
|
1505 | def isvalid(prefix): | |
1518 | try: |
|
1506 | try: | |
1519 | node = self._partialmatch(prefix) |
|
1507 | node = self._partialmatch(prefix) | |
@@ -1532,9 +1520,10 b' class revlog(object):' | |||||
1532 | hexnode = hex(node) |
|
1520 | hexnode = hex(node) | |
1533 |
|
1521 | |||
1534 | def disambiguate(hexnode, minlength): |
|
1522 | def disambiguate(hexnode, minlength): | |
|
1523 | """Disambiguate against wdirid.""" | |||
1535 | for length in range(minlength, 41): |
|
1524 | for length in range(minlength, 41): | |
1536 | prefix = hexnode[:length] |
|
1525 | prefix = hexnode[:length] | |
1537 |
if |
|
1526 | if not maybewdir(prefix): | |
1538 | return prefix |
|
1527 | return prefix | |
1539 |
|
1528 | |||
1540 | if not getattr(self, 'filteredrevs', None): |
|
1529 | if not getattr(self, 'filteredrevs', None): |
@@ -449,8 +449,30 b' def shortesthexnodeidprefix(repo, node, ' | |||||
449 | # _partialmatch() of filtered changelog could take O(len(repo)) time, |
|
449 | # _partialmatch() of filtered changelog could take O(len(repo)) time, | |
450 | # which would be unacceptably slow. so we look for hash collision in |
|
450 | # which would be unacceptably slow. so we look for hash collision in | |
451 | # unfiltered space, which means some hashes may be slightly longer. |
|
451 | # unfiltered space, which means some hashes may be slightly longer. | |
|
452 | cl = repo.unfiltered().changelog | |||
|
453 | ||||
|
454 | def isrev(prefix): | |||
|
455 | try: | |||
|
456 | i = int(prefix) | |||
|
457 | # if we are a pure int, then starting with zero will not be | |||
|
458 | # confused as a rev; or, obviously, if the int is larger | |||
|
459 | # than the value of the tip rev | |||
|
460 | if prefix[0] == '0' or i > len(cl): | |||
|
461 | return False | |||
|
462 | return True | |||
|
463 | except ValueError: | |||
|
464 | return False | |||
|
465 | ||||
|
466 | def disambiguate(prefix): | |||
|
467 | """Disambiguate against revnums.""" | |||
|
468 | hexnode = hex(node) | |||
|
469 | for length in range(len(prefix), 41): | |||
|
470 | prefix = hexnode[:length] | |||
|
471 | if not isrev(prefix): | |||
|
472 | return prefix | |||
|
473 | ||||
452 | try: |
|
474 | try: | |
453 |
return |
|
475 | return disambiguate(cl.shortest(node, minlength)) | |
454 | except error.LookupError: |
|
476 | except error.LookupError: | |
455 | raise error.RepoLookupError() |
|
477 | raise error.RepoLookupError() | |
456 |
|
478 |
General Comments 0
You need to be logged in to leave comments.
Login now