##// END OF EJS Templates
remotephase: fast path newheads computation in simple case (issue5964)...
remotephase: fast path newheads computation in simple case (issue5964) Changeset 88efb7d6bcb6 fixed the logic of `phases.newheads` but greatly regressed its performance (up to many order of magnitude). The first step to fix the regression is to exit early when there is no work to do. If there are no heads to filter or not roots to filter them, we don't have to do any work. This fixes the regression when talking to an all public changeset. The performance is even better than before. pypy, compared to an all public repo ------------------------------------ 8eeed92475d5: 0.005758 seconds 88efb7d6bcb6: 0.602517 seconds (x104) this code: 0.001508 seconds (-74% from base) mercurial compared to an all public repo ---------------------------------------- 8eeed92475d5: 0.000577 seconds 88efb7d6bcb6: 0.185316 seconds (x321) this code: 0.000150 seconds (-74% from base) The performance of newheads, when actual computations are required, is fixed in the next changeset.

File last commit:

r37138:a8a902d7 default
r39181:c89e2fb2 stable
Show More
simplemerge
83 lines | 2.5 KiB | text/plain | TextLexer
#!/usr/bin/env python
from __future__ import absolute_import
import getopt
import sys
import hgdemandimport
hgdemandimport.enable()
from mercurial.i18n import _
from mercurial import (
context,
error,
fancyopts,
simplemerge,
ui as uimod,
)
from mercurial.utils import (
procutil,
)
options = [('L', 'label', [], _('labels to use on conflict markers')),
('a', 'text', None, _('treat all files as text')),
('p', 'print', None,
_('print results instead of overwriting LOCAL')),
('', 'no-minimal', None, _('no effect (DEPRECATED)')),
('h', 'help', None, _('display help and exit')),
('q', 'quiet', None, _('suppress output'))]
usage = _('''simplemerge [OPTS] LOCAL BASE OTHER
Simple three-way file merge utility with a minimal feature set.
Apply to LOCAL the changes necessary to go from BASE to OTHER.
By default, LOCAL is overwritten with the results of this operation.
''')
class ParseError(Exception):
"""Exception raised on errors in parsing the command line."""
def showhelp():
sys.stdout.write(usage)
sys.stdout.write('\noptions:\n')
out_opts = []
for shortopt, longopt, default, desc in options:
out_opts.append(('%2s%s' % (shortopt and '-%s' % shortopt,
longopt and ' --%s' % longopt),
'%s' % desc))
opts_len = max([len(opt[0]) for opt in out_opts])
for first, second in out_opts:
sys.stdout.write(' %-*s %s\n' % (opts_len, first, second))
try:
for fp in (sys.stdin, sys.stdout, sys.stderr):
procutil.setbinary(fp)
opts = {}
try:
args = fancyopts.fancyopts(sys.argv[1:], options, opts)
except getopt.GetoptError as e:
raise ParseError(e)
if opts['help']:
showhelp()
sys.exit(0)
if len(args) != 3:
raise ParseError(_('wrong number of arguments'))
local, base, other = args
sys.exit(simplemerge.simplemerge(uimod.ui.load(),
context.arbitraryfilectx(local),
context.arbitraryfilectx(base),
context.arbitraryfilectx(other),
**opts))
except ParseError as e:
sys.stdout.write("%s: %s\n" % (sys.argv[0], e))
showhelp()
sys.exit(1)
except error.Abort as e:
sys.stderr.write("abort: %s\n" % e)
sys.exit(255)
except KeyboardInterrupt:
sys.exit(255)