Mercurial > hg
annotate tests/test-config-env.py @ 39270:37e56607cbb9
lfs: add a progress bar when searching for blobs to upload
The search itself can take an extreme amount of time if there are a lot of
revisions involved. I've got a local repo that took 6 minutes to push 1850
commits, and 60% of that time was spent here (there are ~70K files):
\ 58.1% wrapper.py: extractpointers line 297: pointers = extractpointers(...
| 57.7% wrapper.py: pointersfromctx line 352: for p in pointersfromctx(ct...
| 57.4% wrapper.py: pointerfromctx line 397: p = pointerfromctx(ctx, f, ...
\ 38.7% context.py: __contains__ line 368: if f not in ctx:
| 38.7% util.py: __get__ line 82: return key in self._manifest
| 38.7% context.py: _manifest line 1416: result = self.func(obj)
| 38.7% manifest.py: read line 472: return self._manifestctx.re...
\ 25.6% revlog.py: revision line 1562: text = rl.revision(self._node)
\ 12.8% revlog.py: _chunks line 2217: bins = self._chunks(chain, ...
| 12.0% revlog.py: decompressline 2112: ladd(decomp(buffer(data, ch...
\ 7.8% revlog.py: checkhash line 2232: self.checkhash(text, node, ...
| 7.8% revlog.py: hash line 2315: if node != self.hash(text, ...
| 7.8% revlog.py: hash line 2242: return hash(text, p1, p2)
\ 12.0% manifest.py: __init__ line 1565: self._data = manifestdict(t...
\ 16.8% context.py: filenode line 378: if not _islfs(fctx.filelog(...
| 15.7% util.py: __get__ line 706: return self._filelog
| 14.8% context.py: _filelog line 1416: result = self.func(obj)
| 14.8% localrepo.py: file line 629: return self._repo.file(self...
| 14.8% filelog.py: __init__ line 1134: return filelog.filelog(self...
| 14.5% revlog.py: __init__ line 24: censorable=True)
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Fri, 24 Aug 2018 17:45:46 -0400 |
parents | d4a2e0d5d042 |
children | 2372284d9457 |
rev | line source |
---|---|
31685
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
1 # Test the config layer generated by environment variables |
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
2 |
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
3 from __future__ import absolute_import, print_function |
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
4 |
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
5 import os |
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
6 |
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
7 from mercurial import ( |
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
8 encoding, |
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
9 rcutil, |
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
10 ui as uimod, |
31857
08fbc97d1364
tests: print Unix style paths in *.py tests
Matt Harbison <matt_harbison@yahoo.com>
parents:
31685
diff
changeset
|
11 util, |
31685
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
12 ) |
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
13 |
37119
d4a2e0d5d042
procutil: bulk-replace util.std* to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36730
diff
changeset
|
14 from mercurial.utils import ( |
d4a2e0d5d042
procutil: bulk-replace util.std* to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36730
diff
changeset
|
15 procutil, |
d4a2e0d5d042
procutil: bulk-replace util.std* to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36730
diff
changeset
|
16 ) |
d4a2e0d5d042
procutil: bulk-replace util.std* to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36730
diff
changeset
|
17 |
36730
a22915edc279
py3: byte-stringify test-config.t and test-config-env.py
Yuya Nishihara <yuya@tcha.org>
parents:
31857
diff
changeset
|
18 testtmp = encoding.environ[b'TESTTMP'] |
31685
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
19 |
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
20 # prepare hgrc files |
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
21 def join(name): |
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
22 return os.path.join(testtmp, name) |
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
23 |
36730
a22915edc279
py3: byte-stringify test-config.t and test-config-env.py
Yuya Nishihara <yuya@tcha.org>
parents:
31857
diff
changeset
|
24 with open(join(b'sysrc'), 'wb') as f: |
a22915edc279
py3: byte-stringify test-config.t and test-config-env.py
Yuya Nishihara <yuya@tcha.org>
parents:
31857
diff
changeset
|
25 f.write(b'[ui]\neditor=e0\n[pager]\npager=p0\n') |
31685
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
26 |
36730
a22915edc279
py3: byte-stringify test-config.t and test-config-env.py
Yuya Nishihara <yuya@tcha.org>
parents:
31857
diff
changeset
|
27 with open(join(b'userrc'), 'wb') as f: |
a22915edc279
py3: byte-stringify test-config.t and test-config-env.py
Yuya Nishihara <yuya@tcha.org>
parents:
31857
diff
changeset
|
28 f.write(b'[ui]\neditor=e1') |
31685
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
29 |
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
30 # replace rcpath functions so they point to the files above |
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
31 def systemrcpath(): |
36730
a22915edc279
py3: byte-stringify test-config.t and test-config-env.py
Yuya Nishihara <yuya@tcha.org>
parents:
31857
diff
changeset
|
32 return [join(b'sysrc')] |
31685
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
33 |
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
34 def userrcpath(): |
36730
a22915edc279
py3: byte-stringify test-config.t and test-config-env.py
Yuya Nishihara <yuya@tcha.org>
parents:
31857
diff
changeset
|
35 return [join(b'userrc')] |
31685
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
36 |
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
37 rcutil.systemrcpath = systemrcpath |
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
38 rcutil.userrcpath = userrcpath |
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
39 os.path.isdir = lambda x: False # hack: do not load default.d/*.rc |
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
40 |
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
41 # utility to print configs |
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
42 def printconfigs(env): |
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
43 encoding.environ = env |
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
44 rcutil._rccomponents = None # reset cache |
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
45 ui = uimod.ui.load() |
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
46 for section, name, value in ui.walkconfig(): |
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
47 source = ui.configsource(section, name) |
37119
d4a2e0d5d042
procutil: bulk-replace util.std* to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36730
diff
changeset
|
48 procutil.stdout.write(b'%s.%s=%s # %s\n' |
d4a2e0d5d042
procutil: bulk-replace util.std* to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36730
diff
changeset
|
49 % (section, name, value, util.pconvert(source))) |
d4a2e0d5d042
procutil: bulk-replace util.std* to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36730
diff
changeset
|
50 procutil.stdout.write(b'\n') |
31685
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
51 |
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
52 # environment variable overrides |
d83e51654c8a
rcutil: let environ override system configs (BC)
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
53 printconfigs({}) |
36730
a22915edc279
py3: byte-stringify test-config.t and test-config-env.py
Yuya Nishihara <yuya@tcha.org>
parents:
31857
diff
changeset
|
54 printconfigs({b'EDITOR': b'e2', b'PAGER': b'p2'}) |