##// END OF EJS Templates
pathcopies: give up any optimization based on `introrev`...
pathcopies: give up any optimization based on `introrev` Between 8a0136f69027 and d98fb3f42f33, we sped up the search for the introduction revision during path copies. However, further checking show that finding the introduction revision is still expensive and that we are better off without it. So we simply drop it and only rely on the linkrev optimisation. I ran `perfpathcopies` on 6989 pair of revision in the pypy repository (`hg perfhelper-pathcopies`. The result is massively in favor of dropping this condition. The result of the copy tracing are unchanged. Attempt to use a smaller changes preserving linkrev usage were unsuccessful, it can return wrong result. The following changesets broke test-mv-cp-st-diff.t - if not f.isintroducedafter(limit): + if limit >= 0 and f.linkrev() < limit: return None Here are various numbers (before this changeset/after this changesets) source destination before after saved-time ratio worth cases e66f24650daf 695dfb0f493b 1.062843 1.246369 -0.183526 1.172675 c979853a3b6a 8d60fe293e79 1.036985 1.196414 -0.159429 1.153743 22349fa2fc33 fbb1c9fd86c0 0.879926 1.038682 -0.158756 1.180420 682b98f3e672 a4878080a536 0.909952 1.063801 -0.153849 1.169074 5adabc9b9848 920958a93997 0.993622 1.147452 -0.153830 1.154817 worse 1% dbfbfcf077e9 aea8f2fd3593 1.016595 1.082999 -0.066404 1.065320 worse 5% c95f1ced15f2 7d29d5e39734 0.453694 0.471156 -0.017462 1.038488 worse 10% 3e144ed1d5b7 2aef0e942480 0.035140 0.037535 -0.002395 1.068156 worse 25% 321fc60db035 801748ba582a 0.009267 0.009325 -0.000058 1.006259 median 2088ce763fc2 e6991321d78b 0.000665 0.000651 0.000014 0.978947 best 25% 915631a97de6 385b31354be6 0.040743 0.040363 0.000380 0.990673 best 10% ad495c36a765 19c10384d3e7 0.431658 0.411490 0.020168 0.953278 best 5% d13ae7d283ae 813c99f810ac 1.141404 1.075346 0.066058 0.942126 best 1% 81593cb4a496 99ae11866969 1.833297 0.063823 1.769474 0.034813 best cases c3b14617fbd7 743a0fcaa4eb 1101.811740 2.735970 1099.075770 0.002483 c3b14617fbd7 9ba6ab77fd29 1116.753953 2.800729 1113.953224 0.002508 058b99d6e81f 57e249b7a3ea 1246.128485 3.042762 1243.085723 0.002442 9a8c361aab49 0354a250d371 1253.111894 3.085796 1250.026098 0.002463 442dbbc53c68 3ec1002a818c 1261.786294 3.138607 1258.647687 0.002487 As one can see, the average case is not really impacted. However, the worth case we get after this changeset are much better than the one we had before it. We have 30 pairs where improvements are above 10 minutes. This reflect in the combined time for all pairs before: 26256s after: 1300s (-95%) If we remove these pathological 30 cases, we still see a significant improvements: before: 1631s after: 1245s (-24%)

File last commit:

r43387:8ff1ecfa default
r43469:c16fe77e default
Show More
split.py
204 lines | 6.5 KiB | text/x-python | PythonLexer
# split.py - split a changeset into smaller ones
#
# Copyright 2015 Laurent Charignon <lcharignon@fb.com>
# Copyright 2017 Facebook, Inc.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
"""command to split a changeset into smaller ones (EXPERIMENTAL)"""
from __future__ import absolute_import
from mercurial.i18n import _
from mercurial.node import (
nullid,
short,
)
from mercurial import (
bookmarks,
cmdutil,
commands,
error,
hg,
obsolete,
phases,
pycompat,
registrar,
revsetlang,
scmutil,
)
# allow people to use split without explicitly enabling rebase extension
from . import rebase
cmdtable = {}
command = registrar.command(cmdtable)
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
# be specifying the version(s) of Mercurial they are tested with, or
# leave the attribute unspecified.
testedwith = b'ships-with-hg-core'
@command(
b'split',
[
(b'r', b'rev', b'', _(b"revision to split"), _(b'REV')),
(b'', b'rebase', True, _(b'rebase descendants after split')),
]
+ cmdutil.commitopts2,
_(b'hg split [--no-rebase] [[-r] REV]'),
helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
helpbasic=True,
)
def split(ui, repo, *revs, **opts):
"""split a changeset into smaller ones
Repeatedly prompt changes and commit message for new changesets until there
is nothing left in the original changeset.
If --rev was not given, split the working directory parent.
By default, rebase connected non-obsoleted descendants onto the new
changeset. Use --no-rebase to avoid the rebase.
"""
opts = pycompat.byteskwargs(opts)
revlist = []
if opts.get(b'rev'):
revlist.append(opts.get(b'rev'))
revlist.extend(revs)
with repo.wlock(), repo.lock(), repo.transaction(b'split') as tr:
revs = scmutil.revrange(repo, revlist or [b'.'])
if len(revs) > 1:
raise error.Abort(_(b'cannot split multiple revisions'))
rev = revs.first()
ctx = repo[rev]
if rev is None or ctx.node() == nullid:
ui.status(_(b'nothing to split\n'))
return 1
if ctx.node() is None:
raise error.Abort(_(b'cannot split working directory'))
# rewriteutil.precheck is not very useful here because:
# 1. null check is done above and it's more friendly to return 1
# instead of abort
# 2. mergestate check is done below by cmdutil.bailifchanged
# 3. unstable check is more complex here because of --rebase
#
# So only "public" check is useful and it's checked directly here.
if ctx.phase() == phases.public:
raise error.Abort(
_(b'cannot split public changeset'),
hint=_(b"see 'hg help phases' for details"),
)
descendants = list(repo.revs(b'(%d::) - (%d)', rev, rev))
alloworphaned = obsolete.isenabled(repo, obsolete.allowunstableopt)
if opts.get(b'rebase'):
# Skip obsoleted descendants and their descendants so the rebase
# won't cause conflicts for sure.
torebase = list(
repo.revs(
b'%ld - (%ld & obsolete())::', descendants, descendants
)
)
if not alloworphaned and len(torebase) != len(descendants):
raise error.Abort(
_(b'split would leave orphaned changesets behind')
)
else:
if not alloworphaned and descendants:
raise error.Abort(
_(b'cannot split changeset with children without rebase')
)
torebase = ()
if len(ctx.parents()) > 1:
raise error.Abort(_(b'cannot split a merge changeset'))
cmdutil.bailifchanged(repo)
# Deactivate bookmark temporarily so it won't get moved unintentionally
bname = repo._activebookmark
if bname and repo._bookmarks[bname] != ctx.node():
bookmarks.deactivate(repo)
wnode = repo[b'.'].node()
top = None
try:
top = dosplit(ui, repo, tr, ctx, opts)
finally:
# top is None: split failed, need update --clean recovery.
# wnode == ctx.node(): wnode split, no need to update.
if top is None or wnode != ctx.node():
hg.clean(repo, wnode, show_stats=False)
if bname:
bookmarks.activate(repo, bname)
if torebase and top:
dorebase(ui, repo, torebase, top)
def dosplit(ui, repo, tr, ctx, opts):
committed = [] # [ctx]
# Set working parent to ctx.p1(), and keep working copy as ctx's content
if ctx.node() != repo.dirstate.p1():
hg.clean(repo, ctx.node(), show_stats=False)
with repo.dirstate.parentchange():
scmutil.movedirstate(repo, ctx.p1())
# Any modified, added, removed, deleted result means split is incomplete
incomplete = lambda repo: any(repo.status()[:4])
# Main split loop
while incomplete(repo):
if committed:
header = _(
b'HG: Splitting %s. So far it has been split into:\n'
) % short(ctx.node())
for c in committed:
firstline = c.description().split(b'\n', 1)[0]
header += _(b'HG: - %s: %s\n') % (short(c.node()), firstline)
header += _(
b'HG: Write commit message for the next split changeset.\n'
)
else:
header = _(
b'HG: Splitting %s. Write commit message for the '
b'first split changeset.\n'
) % short(ctx.node())
opts.update(
{
b'edit': True,
b'interactive': True,
b'message': header + ctx.description(),
}
)
commands.commit(ui, repo, **pycompat.strkwargs(opts))
newctx = repo[b'.']
committed.append(newctx)
if not committed:
raise error.Abort(_(b'cannot split an empty revision'))
scmutil.cleanupnodes(
repo,
{ctx.node(): [c.node() for c in committed]},
operation=b'split',
fixphase=True,
)
return committed[-1]
def dorebase(ui, repo, src, destctx):
rebase.rebase(
ui,
repo,
rev=[revsetlang.formatspec(b'%ld', src)],
dest=revsetlang.formatspec(b'%d', destctx.rev()),
)