Skip to content
Snippets Groups Projects
Commit 6b54f749 authored by Pierre-Yves David's avatar Pierre-Yves David
Browse files

revset: avoid returning duplicates when returning ancestors

Before this patch, _revancestors were giving false result when a revision was
duplicated in the input. Duplicated entry are rare but may happen when using the
`%lx` notation internally.

This series has no visible impact on the performance of the function according
to benchmark.
parent 85544a52
No related branches found
No related tags found
No related merge requests found
......@@ -37,4 +37,10 @@
seen = set()
while h:
current = -heapq.heappop(h)
if current == inputrev:
try:
inputrev = irevs.next()
heapq.heappush(h, -inputrev)
except StopIteration:
pass
if current not in seen:
......@@ -40,10 +46,4 @@
if current not in seen:
if current == inputrev:
try:
inputrev = irevs.next()
heapq.heappush(h, -inputrev)
except StopIteration:
pass
seen.add(current)
yield current
for parent in cl.parentrevs(current)[:cut]:
......
$ HGENCODING=utf-8
$ export HGENCODING
$ cat > testrevset.py << EOF
> import mercurial.revset
>
> baseset = mercurial.revset.baseset
>
> def r3232(repo, subset, x):
> """"simple revset that return [3,2,3,2]
>
> revisions duplicated on purpose.
> """
> if 3 not in subset:
> if 2 in subset:
> return baseset([2,2])
> return baseset()
> return baseset([3,3,2,2])
>
> mercurial.revset.symbols['r3232'] = r3232
> EOF
$ cat >> $HGRCPATH << EOF
> [extensions]
> testrevset=$TESTTMP/testrevset.py
> EOF
$ try() {
> hg debugrevspec --debug "$@"
......@@ -340,6 +362,9 @@
0
$ log 'ancestor(1,2,3,4,5)'
1
test ancestors
$ log 'ancestors(5)'
0
1
......@@ -347,6 +372,12 @@
5
$ log 'ancestor(ancestors(5))'
0
$ log '::r3232()'
0
1
2
3
$ log 'author(bob)'
2
$ log 'author("re:bob|test")'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment