Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 49511:117dcc4a0e67
revset: handle wdir() in `sort(..., -topo)`
The last apparent usage of `repo.changelog.parentrevs` in revsets is in
`children()`, but since the sets being operated on never include wdir(), it's
never called with `wdirrev` and the wdir() arg on the command line is
effectively ignored instead of aborting there. I'm not sure how to fix that.
Before (on a clone of hg):
$ python3.8 hg perf::revset --config extensions.perf=contrib/perf.py 'sort(all(), -topo)'
! wall 0.123663 comb 0.130000 user 0.130000 sys 0.000000 (best of 76)
After:
$ python3.8 hg perf::revset --config extensions.perf=contrib/perf.py 'sort(all(), -topo)'
! wall 0.123838 comb 0.130000 user 0.130000 sys 0.000000 (best of 75)
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Tue, 04 Oct 2022 12:34:50 -0400 |
parents | e02dcc625171 |
children | c55e70bed7eb 76c128d4de4e |
comparison
equal
deleted
inserted
replaced
49510:e02dcc625171 | 49511:117dcc4a0e67 |
---|---|
2472 if len(keyflags) == 1 and keyflags[0][0] == b"rev": | 2472 if len(keyflags) == 1 and keyflags[0][0] == b"rev": |
2473 revs.sort(reverse=keyflags[0][1]) | 2473 revs.sort(reverse=keyflags[0][1]) |
2474 return revs | 2474 return revs |
2475 elif keyflags[0][0] == b"topo": | 2475 elif keyflags[0][0] == b"topo": |
2476 firstbranch = () | 2476 firstbranch = () |
2477 parentrevs = repo.changelog.parentrevs | |
2478 parentsfunc = parentrevs | |
2479 if wdirrev in revs: | |
2480 | |
2481 def parentsfunc(r): | |
2482 try: | |
2483 return parentrevs(r) | |
2484 except error.WdirUnsupported: | |
2485 return [p.rev() for p in repo[None].parents()] | |
2486 | |
2477 if b'topo.firstbranch' in opts: | 2487 if b'topo.firstbranch' in opts: |
2478 firstbranch = getset(repo, subset, opts[b'topo.firstbranch']) | 2488 firstbranch = getset(repo, subset, opts[b'topo.firstbranch']) |
2479 revs = baseset( | 2489 revs = baseset( |
2480 dagop.toposort(revs, repo.changelog.parentrevs, firstbranch), | 2490 dagop.toposort(revs, parentsfunc, firstbranch), |
2481 istopo=True, | 2491 istopo=True, |
2482 ) | 2492 ) |
2483 if keyflags[0][1]: | 2493 if keyflags[0][1]: |
2484 revs.reverse() | 2494 revs.reverse() |
2485 return revs | 2495 return revs |