annotate contrib/simplemerge @ 38602:44f5acfb9ad2

aggressivemergedeltas: enabled the option by default The option has been around for a while (August 2015) but was never turned on by default. In-depth testing shows large wins for having that on with no significant drawbacks. When enabled, revlog consider delta against both p1 and p2 at the same time when storing a revision. Selecting a delta against "p2" can produce better deltas and chain. This raise large benefit for all repositories, especially if they have a lot of merges. Comparison of `.hg/store/` size: mercurial (6.74% merges): before: 54,225,348 bytes after: 47,279,959 bytes -13% pypy (8.30% merges): before: 459,041,759 bytes after: 346,090,067 bytes -25% netbeans (34.21% merges): before: 2,468,041,333 bytes after: 1,364,077,645 bytes -45% mozilla-central (4.84% merges): before: 2,731,799,546 bytes after: 2,157,718,019 bytes -21% Comparison of `00manifest.d` size: mercurial (6.74% merges): before: 11,682,516 bytes after: 6,143,044 bytes -47% pypy (8.30% merges): before: 156,447,163 bytes after: 52,941,780 bytes -66% netbeans (34.21% merges): before: 1,250,363,851 bytes after: 130,088,982 bytes -90% mozilla-central (4.84% merges): before: 468,202,733 bytes after: 215,096,339 bytes -54% In addition, the better deltas help with the performance of multiple core operations. However, better chains mean longer chains, which can affect performance negatively (mostly manifest revision retrieval time). Chains length is a deeper problem that also affects linear repository too. Overall we think the benefits of using p2 as a diff target are bigger than the downsizes. In addition, we are also working on ways to improve the performance impact of chain length, so theses downsizes get fixed in the future. Below are interesting items from the full benchmark run: bundling 100 revisions from pypy: before: 670ms after: 480ms -28% bundle 10000 revisions from pypy: before: 1.38s after: 1.10s -54% bundle 10000 revisions from pypy: before: 16.1s after: 7.81s -52% bundle 10000 revisions from netbeans: before: 19.3s after: 15.5s -19% unbundle 1000 revisions to pypy: before: 641ms after: 315ms - 51% clone mercurial (http): before: 26.0s after: 22.6s -23% pulling 1000 revisions from pypy (shh): before: 2.07s after: 1.36s -44% pushing 1000 revision through http (pypy repository) before: 2.18s after: 1.35s -48% diff time in mozilla-central: before: 1.420s after: 0.983s -31% status time in mozilla-central: before: 1.260s after: 0.828s -34% Impact in other cases seems minimal (within a couple of percent in worse cases) and can be seen in both direction: Timing for a simple `hg commit`: mozilla-central: before: 3.37s after: 3.22s -4% pypy: before: 194ms after: 197ms +2% Timing for status (from tip to parent of tip): mercurial: before: 52.4ms after: 52.4ms (same) pypy: before: 55.2 after: 56.9 +3% Timing for `hg update` mozilla-central, across 10 revisions: before: 4.82s after: 4.59s -5% mozilla-central, across 10000 revisions: before: 49.1s after: 49.9s +2% pypy, across 10 revisions: before: 213ms after: 216ms +1% pypy, across 10000 revisions: before: 5.31ms after: 5.24ms -1% The negative consequences are related to manifest fetch time: (timing for the tip revision tested by the benchmark) pypy-2018: before: 2.60ms after: 3.88ms +50% mozilla-central-2018: before: 565ms after: 652ms +15% (~+100ms) netbeans-2018: before: 101ms after: 250ms +48% (~+150ms) This shows up as a fixed overhead on some command we benchmarked: no-op push of mozilla-central: before: 945ms after: 1040ms +10% (~+100ms) pushing 10 changeset in netbeabs over ssh: before: 557ms after: 712ms +28% (+155ms) pushing 100 changeset in netbeabs over ssh: before: 592ms after: 771ms +30% (+179ms)
author Paul Morelle <paul.morelle@octobus.net>
date Fri, 22 Jun 2018 01:42:38 +0200
parents a8a902d7176e
children d3e940a32be0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4363
2e3c54fb79a3 actually port simplemerge to hg
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4362
diff changeset
1 #!/usr/bin/env python
33895
aed91971d88c simplemerge: update to conform with modern import conventions
Augie Fackler <raf@durin42.com>
parents: 30576
diff changeset
2 from __future__ import absolute_import
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
3
30576
541949a10a68 fancyopts: switch from fancyopts.getopt.* to getopt.*
Pulkit Goyal <7895pulkit@gmail.com>
parents: 30559
diff changeset
4 import getopt
19378
9de689d20230 cleanup: drop unused variables and an unused import
Simon Heimberg <simohe@besonet.ch>
parents: 19022
diff changeset
5 import sys
33895
aed91971d88c simplemerge: update to conform with modern import conventions
Augie Fackler <raf@durin42.com>
parents: 30576
diff changeset
6
aed91971d88c simplemerge: update to conform with modern import conventions
Augie Fackler <raf@durin42.com>
parents: 30576
diff changeset
7 import hgdemandimport
aed91971d88c simplemerge: update to conform with modern import conventions
Augie Fackler <raf@durin42.com>
parents: 30576
diff changeset
8 hgdemandimport.enable()
aed91971d88c simplemerge: update to conform with modern import conventions
Augie Fackler <raf@durin42.com>
parents: 30576
diff changeset
9
4363
2e3c54fb79a3 actually port simplemerge to hg
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4362
diff changeset
10 from mercurial.i18n import _
33895
aed91971d88c simplemerge: update to conform with modern import conventions
Augie Fackler <raf@durin42.com>
parents: 30576
diff changeset
11 from mercurial import (
34051
d2fc88426d21 context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents: 34050
diff changeset
12 context,
33895
aed91971d88c simplemerge: update to conform with modern import conventions
Augie Fackler <raf@durin42.com>
parents: 30576
diff changeset
13 error,
aed91971d88c simplemerge: update to conform with modern import conventions
Augie Fackler <raf@durin42.com>
parents: 30576
diff changeset
14 fancyopts,
aed91971d88c simplemerge: update to conform with modern import conventions
Augie Fackler <raf@durin42.com>
parents: 30576
diff changeset
15 simplemerge,
aed91971d88c simplemerge: update to conform with modern import conventions
Augie Fackler <raf@durin42.com>
parents: 30576
diff changeset
16 ui as uimod,
37120
a8a902d7176e procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents: 34051
diff changeset
17 )
a8a902d7176e procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents: 34051
diff changeset
18 from mercurial.utils import (
a8a902d7176e procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents: 34051
diff changeset
19 procutil,
33895
aed91971d88c simplemerge: update to conform with modern import conventions
Augie Fackler <raf@durin42.com>
parents: 30576
diff changeset
20 )
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
21
4364
d5c3a70f8422 polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4363
diff changeset
22 options = [('L', 'label', [], _('labels to use on conflict markers')),
d5c3a70f8422 polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4363
diff changeset
23 ('a', 'text', None, _('treat all files as text')),
d5c3a70f8422 polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4363
diff changeset
24 ('p', 'print', None,
d5c3a70f8422 polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4363
diff changeset
25 _('print results instead of overwriting LOCAL')),
22023
f18830651811 simplemerge: burn "minimal" feature to the ground
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 19378
diff changeset
26 ('', 'no-minimal', None, _('no effect (DEPRECATED)')),
4364
d5c3a70f8422 polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4363
diff changeset
27 ('h', 'help', None, _('display help and exit')),
d5c3a70f8422 polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4363
diff changeset
28 ('q', 'quiet', None, _('suppress output'))]
d5c3a70f8422 polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4363
diff changeset
29
d5c3a70f8422 polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4363
diff changeset
30 usage = _('''simplemerge [OPTS] LOCAL BASE OTHER
d5c3a70f8422 polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4363
diff changeset
31
d5c3a70f8422 polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4363
diff changeset
32 Simple three-way file merge utility with a minimal feature set.
5081
ea7b982b6c08 Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4408
diff changeset
33
4364
d5c3a70f8422 polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4363
diff changeset
34 Apply to LOCAL the changes necessary to go from BASE to OTHER.
5081
ea7b982b6c08 Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4408
diff changeset
35
4364
d5c3a70f8422 polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4363
diff changeset
36 By default, LOCAL is overwritten with the results of this operation.
d5c3a70f8422 polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4363
diff changeset
37 ''')
d5c3a70f8422 polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4363
diff changeset
38
6002
abd66eb0889e merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents: 5081
diff changeset
39 class ParseError(Exception):
abd66eb0889e merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents: 5081
diff changeset
40 """Exception raised on errors in parsing the command line."""
abd66eb0889e merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents: 5081
diff changeset
41
4364
d5c3a70f8422 polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4363
diff changeset
42 def showhelp():
d5c3a70f8422 polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4363
diff changeset
43 sys.stdout.write(usage)
d5c3a70f8422 polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4363
diff changeset
44 sys.stdout.write('\noptions:\n')
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
45
4364
d5c3a70f8422 polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4363
diff changeset
46 out_opts = []
d5c3a70f8422 polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4363
diff changeset
47 for shortopt, longopt, default, desc in options:
d5c3a70f8422 polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4363
diff changeset
48 out_opts.append(('%2s%s' % (shortopt and '-%s' % shortopt,
d5c3a70f8422 polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4363
diff changeset
49 longopt and ' --%s' % longopt),
d5c3a70f8422 polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4363
diff changeset
50 '%s' % desc))
d5c3a70f8422 polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4363
diff changeset
51 opts_len = max([len(opt[0]) for opt in out_opts])
d5c3a70f8422 polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4363
diff changeset
52 for first, second in out_opts:
d5c3a70f8422 polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4363
diff changeset
53 sys.stdout.write(' %-*s %s\n' % (opts_len, first, second))
d5c3a70f8422 polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4363
diff changeset
54
6002
abd66eb0889e merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents: 5081
diff changeset
55 try:
7080
a6477aa893b8 tests: Windows compatibility fixes
Patrick Mezard <pmezard@gmail.com>
parents: 6002
diff changeset
56 for fp in (sys.stdin, sys.stdout, sys.stderr):
37120
a8a902d7176e procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents: 34051
diff changeset
57 procutil.setbinary(fp)
19022
cba222f01056 tests: run check-code on Python files without .py extension
Mads Kiilerich <madski@unity3d.com>
parents: 14233
diff changeset
58
6002
abd66eb0889e merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents: 5081
diff changeset
59 opts = {}
4364
d5c3a70f8422 polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4363
diff changeset
60 try:
6002
abd66eb0889e merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents: 5081
diff changeset
61 args = fancyopts.fancyopts(sys.argv[1:], options, opts)
30576
541949a10a68 fancyopts: switch from fancyopts.getopt.* to getopt.*
Pulkit Goyal <7895pulkit@gmail.com>
parents: 30559
diff changeset
62 except getopt.GetoptError as e:
6002
abd66eb0889e merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents: 5081
diff changeset
63 raise ParseError(e)
abd66eb0889e merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents: 5081
diff changeset
64 if opts['help']:
4364
d5c3a70f8422 polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4363
diff changeset
65 showhelp()
6002
abd66eb0889e merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents: 5081
diff changeset
66 sys.exit(0)
abd66eb0889e merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents: 5081
diff changeset
67 if len(args) != 3:
abd66eb0889e merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents: 5081
diff changeset
68 raise ParseError(_('wrong number of arguments'))
33903
ed6f64173121 contrib: make simplemerge script pass context-like objects
Phil Cohen <phillco@fb.com>
parents: 33895
diff changeset
69 local, base, other = args
ed6f64173121 contrib: make simplemerge script pass context-like objects
Phil Cohen <phillco@fb.com>
parents: 33895
diff changeset
70 sys.exit(simplemerge.simplemerge(uimod.ui.load(),
34051
d2fc88426d21 context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents: 34050
diff changeset
71 context.arbitraryfilectx(local),
d2fc88426d21 context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents: 34050
diff changeset
72 context.arbitraryfilectx(base),
d2fc88426d21 context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents: 34050
diff changeset
73 context.arbitraryfilectx(other),
33903
ed6f64173121 contrib: make simplemerge script pass context-like objects
Phil Cohen <phillco@fb.com>
parents: 33895
diff changeset
74 **opts))
28047
863075fd4cd0 misc: use modern exception syntax
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 26587
diff changeset
75 except ParseError as e:
6002
abd66eb0889e merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents: 5081
diff changeset
76 sys.stdout.write("%s: %s\n" % (sys.argv[0], e))
abd66eb0889e merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents: 5081
diff changeset
77 showhelp()
abd66eb0889e merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents: 5081
diff changeset
78 sys.exit(1)
28047
863075fd4cd0 misc: use modern exception syntax
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 26587
diff changeset
79 except error.Abort as e:
6002
abd66eb0889e merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents: 5081
diff changeset
80 sys.stderr.write("abort: %s\n" % e)
abd66eb0889e merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents: 5081
diff changeset
81 sys.exit(255)
abd66eb0889e merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents: 5081
diff changeset
82 except KeyboardInterrupt:
abd66eb0889e merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents: 5081
diff changeset
83 sys.exit(255)