revset: fix nth ancestor revset w/ multiple bases

Summary: The nth ancestor revset was crashing with multiple base revisions, e.g. "(. + .^)~". Fix variable shadowing issue in revset.ancestorspec.

Differential Revision: D30375233

fbshipit-source-id: 37a78bf1000a40872600e587733a84029f68343b
This commit is contained in:
Muir Manders 2021-08-20 12:26:08 -07:00 committed by Facebook GitHub Bot
parent 50cf59e766
commit a75c3e60e3
2 changed files with 9 additions and 3 deletions

View File

@ -576,9 +576,9 @@ def ancestorspec(repo, subset, x, n, order):
nullrev = node.nullrev
for r in s:
if r != nullrev:
n = firstancestornth(tonode(r), n)
if n is not None:
psadd(torev(n))
ancestor = firstancestornth(tonode(r), n)
if ancestor is not None:
psadd(torev(ancestor))
return subset & baseset(ps, repo=repo)

View File

@ -2680,3 +2680,9 @@ sh % "hg log -r '\n. +\n.^ +'" == r"""
( . + .^ +
^ here)
[255]"""
# test ancestorspec with multiple base revisions
sh % "log '(. + .^)~1'" == r"""
4
8"""