Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 32436:f064e2f72c49
revset: add support for "wdir()^n"
This patch catches the WdirUnsupported exception raised, and adds support for
wdir^n which will give us the nth parent of the working directory.
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Mon, 22 May 2017 01:01:45 +0530 |
parents | bb5dc19484b8 |
children | 14482f8e6ce6 |
comparison
equal
deleted
inserted
replaced
32435:bb5dc19484b8 | 32436:f064e2f72c49 |
---|---|
1500 cl = repo.changelog | 1500 cl = repo.changelog |
1501 for r in getset(repo, fullreposet(repo), x): | 1501 for r in getset(repo, fullreposet(repo), x): |
1502 if n == 0: | 1502 if n == 0: |
1503 ps.add(r) | 1503 ps.add(r) |
1504 elif n == 1: | 1504 elif n == 1: |
1505 ps.add(cl.parentrevs(r)[0]) | 1505 try: |
1506 ps.add(cl.parentrevs(r)[0]) | |
1507 except error.WdirUnsupported: | |
1508 ps.add(repo[r].parents()[0].rev()) | |
1506 elif n == 2: | 1509 elif n == 2: |
1507 parents = cl.parentrevs(r) | 1510 try: |
1508 if parents[1] != node.nullrev: | 1511 parents = cl.parentrevs(r) |
1509 ps.add(parents[1]) | 1512 if parents[1] != node.nullrev: |
1513 ps.add(parents[1]) | |
1514 except error.WdirUnsupported: | |
1515 parents = repo[r].parents() | |
1516 if len(parents) == 2: | |
1517 ps.add(parents[1].rev()) | |
1510 return subset & ps | 1518 return subset & ps |
1511 | 1519 |
1512 @predicate('present(set)', safe=True) | 1520 @predicate('present(set)', safe=True) |
1513 def present(repo, subset, x): | 1521 def present(repo, subset, x): |
1514 """An empty set, if any revision in set isn't found; otherwise, | 1522 """An empty set, if any revision in set isn't found; otherwise, |