Details
Details
- Reviewers
lothiraldan - Group Reviewers
hg-reviewers - Commits
- rHGa01200b25da6: shortest: use 'x' prefix to disambiguate from revnum if configured
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
lothiraldan |
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/scmutil.py (6 lines) | |||
M | tests/test-template-functions.t (5 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
Martin von Zweigbergk | Apr 17 2018, 2:49 AM |
Status | Author | Revision | |
---|---|---|---|
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz |
def shortesthexnodeidprefix(repo, node, minlength=1): | def shortesthexnodeidprefix(repo, node, minlength=1): | ||||
"""Find the shortest unambiguous prefix that matches hexnode.""" | """Find the shortest unambiguous prefix that matches hexnode.""" | ||||
# _partialmatch() of filtered changelog could take O(len(repo)) time, | # _partialmatch() of filtered changelog could take O(len(repo)) time, | ||||
# which would be unacceptably slow. so we look for hash collision in | # which would be unacceptably slow. so we look for hash collision in | ||||
# unfiltered space, which means some hashes may be slightly longer. | # unfiltered space, which means some hashes may be slightly longer. | ||||
def disambiguate(prefix): | def disambiguate(prefix): | ||||
"""Disambiguate against revnums.""" | """Disambiguate against revnums.""" | ||||
if repo.ui.configbool('experimental', 'revisions.prefixhexnode'): | |||||
if mayberevnum(repo, prefix): | |||||
return 'x' + prefix | |||||
else: | |||||
return prefix | |||||
hexnode = hex(node) | hexnode = hex(node) | ||||
for length in range(len(prefix), len(hexnode) + 1): | for length in range(len(prefix), len(hexnode) + 1): | ||||
prefix = hexnode[:length] | prefix = hexnode[:length] | ||||
if not mayberevnum(repo, prefix): | if not mayberevnum(repo, prefix): | ||||
return prefix | return prefix | ||||
cl = repo.unfiltered().changelog | cl = repo.unfiltered().changelog | ||||
revset = repo.ui.config('experimental', 'revisions.disambiguatewithin') | revset = repo.ui.config('experimental', 'revisions.disambiguatewithin') |
node '10' conflicts with the revision number '10' even if it is hidden | node '10' conflicts with the revision number '10' even if it is hidden | ||||
(we could exclude hidden revision numbers, but currently we don't) | (we could exclude hidden revision numbers, but currently we don't) | ||||
$ hg log -r 4 -T '{rev}:{shortest(node, 0)}\n' | $ hg log -r 4 -T '{rev}:{shortest(node, 0)}\n' | ||||
4:107 | 4:107 | ||||
$ hg log -r 4 -T '{rev}:{shortest(node, 0)}\n' --hidden | $ hg log -r 4 -T '{rev}:{shortest(node, 0)}\n' --hidden | ||||
4:107 | 4:107 | ||||
$ hg --config experimental.revisions.prefixhexnode=yes log -r 4 -T '{rev}:{shortest(node, 0)}\n' | |||||
4:x10 | |||||
$ hg --config experimental.revisions.prefixhexnode=yes log -r 4 -T '{rev}:{shortest(node, 0)}\n' --hidden | |||||
4:x10 | |||||
node 'c562' should be unique if the other 'c562' nodes are hidden | node 'c562' should be unique if the other 'c562' nodes are hidden | ||||
(but we don't try the slow path to filter out hidden nodes for now) | (but we don't try the slow path to filter out hidden nodes for now) | ||||
$ hg log -r 8 -T '{rev}:{node|shortest}\n' | $ hg log -r 8 -T '{rev}:{node|shortest}\n' | ||||
8:c5625 | 8:c5625 | ||||
$ hg log -r 8:10 -T '{rev}:{node|shortest}\n' --hidden | $ hg log -r 8:10 -T '{rev}:{node|shortest}\n' --hidden | ||||
8:c5625 | 8:c5625 | ||||
9:c5623 | 9:c5623 |