Update revset in hg rebase --restack

Summary: Benchmarking `hg rebase --restack` against `hg evolve --all` showed that `hg rebase --restack` was spending a lot of time on a single revset to identify the current stack of commits. This diff changes the revset to an equivalent but more efficient one.

Test Plan:
All unit tests still pass.

For benchmarking, I created a stack of 4 commits on top of remote/master in fbsource/fbcode. I amended the second commit and then ran the command. Here is profiler output for both before and after the change:

Before (10.87 seconds): P56747821
After (7.58 seconds): P56747927

Based on the profiler output, this change results in a 30% performance improvement in this case.

Reviewers: durham, #sourcecontrol, quark

Reviewed By: quark

Subscribers: quark, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4038630

Tasks: 13976698

Signature: t1:4038630:1476825563:02da1d4e459f780de41d852f88da789513aba7dc
This commit is contained in:
Arun Kulshreshtha 2016-10-18 14:20:37 -07:00
parent af148df6e7
commit 6d9d6b699f

View File

@ -594,7 +594,7 @@ def _findrestackbase(repo):
# Move down current stack until we find a changeset with visible
# precursors or successors, indicating that we may need to stabilize
# some descendants of this changeset or its precursors.
stack = repo.revs('. %% public()')
stack = repo.revs('::. & draft()')
stack.reverse()
for rev in stack:
# Is this the latest version of this changeset? If not, we need