# HG changeset patch # User Laurent Charignon # Date 1447883246 28800 # Node ID 50e683d9835e1127aef63b9b836902227502b44c # Parent 9afe9e0191a121e6ebea2c1e6a622cc7e7fe566f directaccess: fix case of shortened hash containing only digits For directaccess, there are four cases for what looks like short hashes made of digits only: 1 | the hash is a revision number and not a short hash for another revision: we don't change the visibility 2 | the hash is a revision number and a short hash for another revision: we don't change the visibility 3 | the hash is not a revision number and not a short hash for another revision: we don't change the visibility 4 | the hash is not a revision number but is a short hash for another revision: we make it visible Before the patch we were not lifting visibility in case number 4. This patch fixes the issue. diff -r 9afe9e0191a1 -r 50e683d9835e hgext/directaccess.py --- a/hgext/directaccess.py Tue Nov 17 17:06:07 2015 -0800 +++ b/hgext/directaccess.py Wed Nov 18 13:47:26 2015 -0800 @@ -131,7 +131,7 @@ _listtuple = ('symbol', '_list') -def gethashsymbols(tree): +def gethashsymbols(tree, maxrev): # Returns the list of symbols of the tree that look like hashes # for example for the revset 3::abe3ff it will return ('abe3ff') if not tree: @@ -139,8 +139,12 @@ if len(tree) == 2 and tree[0] == "symbol": try: - int(tree[1]) - return [] + n = int(tree[1]) + # This isn't necessarily a rev number, could be a hash prefix + if n > maxrev: + return [tree[1]] + else: + return [] except ValueError as e: if hashre.match(tree[1]): return [tree[1]] @@ -155,7 +159,7 @@ elif len(tree) >= 3: results = [] for subtree in tree[1:]: - results += gethashsymbols(subtree) + results += gethashsymbols(subtree, maxrev) return results else: return [] @@ -171,8 +175,8 @@ if filternm is not None and filternm.startswith('visible-directaccess'): prelength = len(repo._explicitaccess) accessbefore = set(repo._explicitaccess) - repo.symbols = gethashsymbols(tree) cl = repo.unfiltered().changelog + repo.symbols = gethashsymbols(tree, len(cl)) for node in repo.symbols: try: node = cl._partialmatch(node) diff -r 9afe9e0191a1 -r 50e683d9835e tests/test-inhibit.t --- a/tests/test-inhibit.t Tue Nov 17 17:06:07 2015 -0800 +++ b/tests/test-inhibit.t Wed Nov 18 13:47:26 2015 -0800 @@ -525,8 +525,14 @@ |/ o 14:d66ccb8c5871 add cL | - $ hg strip -r 104eed5354c7 - 1 changesets pruned + $ hg strip -r 210589181b14 + 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + working directory now at d66ccb8c5871 + 2 changesets pruned + +Using a hash prefix solely made of digits should work + $ hg update 210589181 + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg rebase -d 18 -r 16 --keep rebasing 16:a438c045eb37 "add cN" $ hg log -r 14:: -G