Show More
@@ -0,0 +1,37 b'' | |||||
|
1 | $ hg init repo | |||
|
2 | $ cd repo | |||
|
3 | ||||
|
4 | $ echo 0 > a | |||
|
5 | $ hg ci -qAm 0 | |||
|
6 | $ for i in 5 8 14 43; do | |||
|
7 | > hg up -q 0 | |||
|
8 | > echo $i > a | |||
|
9 | > hg ci -qm $i | |||
|
10 | > done | |||
|
11 | $ cat <<EOF >> .hg/hgrc | |||
|
12 | > [alias] | |||
|
13 | > l = log -T '{rev}:{shortest(node,1)}\n' | |||
|
14 | > EOF | |||
|
15 | ||||
|
16 | $ hg l | |||
|
17 | 4:7ba5d | |||
|
18 | 3:7ba57 | |||
|
19 | 2:72 | |||
|
20 | 1:9 | |||
|
21 | 0:b | |||
|
22 | $ cat <<EOF >> .hg/hgrc | |||
|
23 | > [experimental] | |||
|
24 | > revisions.disambiguatewithin=:3 | |||
|
25 | > EOF | |||
|
26 | 9 was unambiguous and still is | |||
|
27 | $ hg l -r 9 | |||
|
28 | 1:9 | |||
|
29 | 7 was ambiguous and still is | |||
|
30 | $ hg l -r 7 | |||
|
31 | abort: 00changelog.i@7: ambiguous identifier! | |||
|
32 | [255] | |||
|
33 | 7b is no longer ambiguous | |||
|
34 | $ hg l -r 7b | |||
|
35 | 3:7ba57 | |||
|
36 | ||||
|
37 | $ cd .. |
@@ -590,6 +590,9 b" coreconfigitem('experimental', 'removeem" | |||||
590 | coreconfigitem('experimental', 'revlogv2', |
|
590 | coreconfigitem('experimental', 'revlogv2', | |
591 | default=None, |
|
591 | default=None, | |
592 | ) |
|
592 | ) | |
|
593 | coreconfigitem('experimental', 'revisions.disambiguatewithin', | |||
|
594 | default=None, | |||
|
595 | ) | |||
593 | coreconfigitem('experimental', 'single-head-per-branch', |
|
596 | coreconfigitem('experimental', 'single-head-per-branch', | |
594 | default=False, |
|
597 | default=False, | |
595 | ) |
|
598 | ) |
@@ -437,9 +437,26 b' def formatrevnode(ui, rev, node):' | |||||
437 | return '%d:%s' % (rev, hexfunc(node)) |
|
437 | return '%d:%s' % (rev, hexfunc(node)) | |
438 |
|
438 | |||
439 | def resolvehexnodeidprefix(repo, prefix): |
|
439 | def resolvehexnodeidprefix(repo, prefix): | |
|
440 | try: | |||
440 | # Uses unfiltered repo because it's faster when prefix is ambiguous/ |
|
441 | # Uses unfiltered repo because it's faster when prefix is ambiguous/ | |
441 | # This matches the shortesthexnodeidprefix() function below. |
|
442 | # This matches the shortesthexnodeidprefix() function below. | |
442 | node = repo.unfiltered().changelog._partialmatch(prefix) |
|
443 | node = repo.unfiltered().changelog._partialmatch(prefix) | |
|
444 | except error.AmbiguousPrefixLookupError: | |||
|
445 | revset = repo.ui.config('experimental', 'revisions.disambiguatewithin') | |||
|
446 | if revset: | |||
|
447 | # Clear config to avoid infinite recursion | |||
|
448 | configoverrides = {('experimental', | |||
|
449 | 'revisions.disambiguatewithin'): None} | |||
|
450 | with repo.ui.configoverride(configoverrides): | |||
|
451 | revs = repo.anyrevs([revset], user=True) | |||
|
452 | matches = [] | |||
|
453 | for rev in revs: | |||
|
454 | node = repo.changelog.node(rev) | |||
|
455 | if hex(node).startswith(prefix): | |||
|
456 | matches.append(node) | |||
|
457 | if len(matches) == 1: | |||
|
458 | return matches[0] | |||
|
459 | raise | |||
443 | if node is None: |
|
460 | if node is None: | |
444 | return |
|
461 | return | |
445 | repo.changelog.rev(node) # make sure node isn't filtered |
|
462 | repo.changelog.rev(node) # make sure node isn't filtered |
General Comments 0
You need to be logged in to leave comments.
Login now