Mercurial > hg
annotate mercurial/scmwindows.py @ 32151:4d504e541d3d
rebase: use matcher to optimize manifestmerge
The old merge code would call manifestmerge and calculate the complete diff
between the source to the destination. In many cases, like rebase, the vast
majority of differences between the source and destination are irrelevant
because they are differences between the destination and the common ancestor
only, and therefore don't affect the merge. Since most actions are 'keep', all
the effort to compute them is wasted.
Instead, let's compute the difference between the source and the common ancestor
and only perform the diff of those files against the merge destination. When
using treemanifest, this lets us avoid loading almost the entire tree when
rebasing from a very old ancestor. This speeds up rebase of an old stack of 27
commits by 20x.
In mozilla-central, without treemanifest, when rebasing a commit from
default~100000 to default, this speeds up the manifestmerge step from 2.6s to
1.2s. However, the additional diff adds an overhead to all manifestmerge calls,
especially for flat manifests. When rebasing a commit from default~1 to default
it appears to add 100ms in mozilla-central. While we could put this optimization
behind a flag, I think the fact that it makes merge O(number of changes being
applied) instead of O(number of changes between X and Y) justifies it.
author | Durham Goode <durham@fb.com> |
---|---|
date | Wed, 03 May 2017 10:43:59 -0700 |
parents | bf5e13e38390 |
children | d74b0cff94a9 |
rev | line source |
---|---|
27481
029f02757c20
scmwindows: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26625
diff
changeset
|
1 from __future__ import absolute_import |
029f02757c20
scmwindows: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26625
diff
changeset
|
2 |
18690
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
3 import os |
27481
029f02757c20
scmwindows: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26625
diff
changeset
|
4 |
029f02757c20
scmwindows: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26625
diff
changeset
|
5 from . import ( |
30637
344e68882cd3
py3: replace os.environ with encoding.environ (part 4 of 5)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30612
diff
changeset
|
6 encoding, |
27481
029f02757c20
scmwindows: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26625
diff
changeset
|
7 osutil, |
30612
d623cc6b3742
py3: replace os.pathsep with pycompat.ospathsep
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30314
diff
changeset
|
8 pycompat, |
27481
029f02757c20
scmwindows: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26625
diff
changeset
|
9 util, |
30309
4b1af1c867fa
scmutil: move util.termwidth()
Yuya Nishihara <yuya@tcha.org>
parents:
29760
diff
changeset
|
10 win32, |
27481
029f02757c20
scmwindows: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26625
diff
changeset
|
11 ) |
18690
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
12 |
29760
3df9f780c90e
py3: conditionalize _winreg import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27481
diff
changeset
|
13 try: |
3df9f780c90e
py3: conditionalize _winreg import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27481
diff
changeset
|
14 import _winreg as winreg |
3df9f780c90e
py3: conditionalize _winreg import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27481
diff
changeset
|
15 winreg.CloseKey |
3df9f780c90e
py3: conditionalize _winreg import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27481
diff
changeset
|
16 except ImportError: |
3df9f780c90e
py3: conditionalize _winreg import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27481
diff
changeset
|
17 import winreg |
3df9f780c90e
py3: conditionalize _winreg import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27481
diff
changeset
|
18 |
32078
bf5e13e38390
pager: use less as a fallback on Unix
Yuya Nishihara <yuya@tcha.org>
parents:
30637
diff
changeset
|
19 # MS-DOS 'more' is the only pager available by default on Windows. |
bf5e13e38390
pager: use less as a fallback on Unix
Yuya Nishihara <yuya@tcha.org>
parents:
30637
diff
changeset
|
20 fallbackpager = 'more' |
bf5e13e38390
pager: use less as a fallback on Unix
Yuya Nishihara <yuya@tcha.org>
parents:
30637
diff
changeset
|
21 |
18690
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
22 def systemrcpath(): |
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
23 '''return default os-specific hgrc search path''' |
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
24 rcpath = [] |
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
25 filename = util.executablepath() |
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
26 # Use mercurial.ini found in directory with hg.exe |
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
27 progrc = os.path.join(os.path.dirname(filename), 'mercurial.ini') |
26625
adae8928fe09
windows: read all global config files, not just the first (issue4491) (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
22583
diff
changeset
|
28 rcpath.append(progrc) |
18690
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
29 # Use hgrc.d found in directory with hg.exe |
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
30 progrcd = os.path.join(os.path.dirname(filename), 'hgrc.d') |
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
31 if os.path.isdir(progrcd): |
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
32 for f, kind in osutil.listdir(progrcd): |
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
33 if f.endswith('.rc'): |
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
34 rcpath.append(os.path.join(progrcd, f)) |
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
35 # else look for a system rcpath in the registry |
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
36 value = util.lookupreg('SOFTWARE\\Mercurial', None, |
29760
3df9f780c90e
py3: conditionalize _winreg import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27481
diff
changeset
|
37 winreg.HKEY_LOCAL_MACHINE) |
18690
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
38 if not isinstance(value, str) or not value: |
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
39 return rcpath |
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
40 value = util.localpath(value) |
30612
d623cc6b3742
py3: replace os.pathsep with pycompat.ospathsep
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30314
diff
changeset
|
41 for p in value.split(pycompat.ospathsep): |
18690
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
42 if p.lower().endswith('mercurial.ini'): |
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
43 rcpath.append(p) |
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
44 elif os.path.isdir(p): |
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
45 for f, kind in osutil.listdir(p): |
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
46 if f.endswith('.rc'): |
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
47 rcpath.append(os.path.join(p, f)) |
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
48 return rcpath |
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
49 |
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
50 def userrcpath(): |
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
51 '''return os-specific hgrc search path to the user dir''' |
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
52 home = os.path.expanduser('~') |
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
53 path = [os.path.join(home, 'mercurial.ini'), |
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
54 os.path.join(home, '.hgrc')] |
30637
344e68882cd3
py3: replace os.environ with encoding.environ (part 4 of 5)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30612
diff
changeset
|
55 userprofile = encoding.environ.get('USERPROFILE') |
22583
23c995ed466b
config: don't read the same config file twice
Mads Kiilerich <madski@unity3d.com>
parents:
18712
diff
changeset
|
56 if userprofile and userprofile != home: |
18690
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
57 path.append(os.path.join(userprofile, 'mercurial.ini')) |
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
58 path.append(os.path.join(userprofile, '.hgrc')) |
4c6f7f0dadab
scmutil: split platform-specific bits into their own modules
Kevin Bullock <kbullock@ringworld.org>
parents:
diff
changeset
|
59 return path |
30309
4b1af1c867fa
scmutil: move util.termwidth()
Yuya Nishihara <yuya@tcha.org>
parents:
29760
diff
changeset
|
60 |
30314
365812902904
scmutil: extend termwidth() to return terminal height, renamed to termsize()
Yuya Nishihara <yuya@tcha.org>
parents:
30310
diff
changeset
|
61 def termsize(ui): |
365812902904
scmutil: extend termwidth() to return terminal height, renamed to termsize()
Yuya Nishihara <yuya@tcha.org>
parents:
30310
diff
changeset
|
62 return win32.termsize() |