##// END OF EJS Templates
revlog: make _partialmatch fail fast on almost-hex inputs...
Arseniy Alekseyev -
r50310:5fe7e9ed default
parent child Browse files
Show More
@@ -235,6 +235,8 b' FILE_TOO_SHORT_MSG = _('
235 235 b' expected %d bytes from offset %d, data size is %d'
236 236 )
237 237
238 hexdigits = b'0123456789abcdefABCDEF'
239
238 240
239 241 class revlog:
240 242 """
@@ -1509,7 +1511,7 b' class revlog:'
1509 1511 ambiguous = True
1510 1512 # fall through to slow path that filters hidden revisions
1511 1513 except (AttributeError, ValueError):
1512 # we are pure python, or key was too short to search radix tree
1514 # we are pure python, or key is not hex
1513 1515 pass
1514 1516 if ambiguous:
1515 1517 raise error.AmbiguousPrefixLookupError(
@@ -1523,6 +1525,11 b' class revlog:'
1523 1525 # hex(node)[:...]
1524 1526 l = len(id) // 2 * 2 # grab an even number of digits
1525 1527 try:
1528 # we're dropping the last digit, so let's check that it's hex,
1529 # to avoid the expensive computation below if it's not
1530 if len(id) % 2 > 0:
1531 if not (id[-1] in hexdigits):
1532 return None
1526 1533 prefix = bin(id[:l])
1527 1534 except binascii.Error:
1528 1535 pass
General Comments 0
You need to be logged in to leave comments. Login now