Show More
@@ -50,7 +50,7 b" outputre = re.compile((r'! wall (\\d+.\\d+" | |||
|
50 | 50 | |
|
51 | 51 | def runperfcommand(reponame, command, *args, **kwargs): |
|
52 | 52 | os.environ["HGRCPATH"] = os.environ.get("ASVHGRCPATH", "") |
|
53 | ui = uimod.ui() | |
|
53 | ui = uimod.ui.load() | |
|
54 | 54 | repo = hg.repository(ui, os.path.join(reposdir, reponame)) |
|
55 | 55 | perfext = extensions.load(ui, 'perfext', |
|
56 | 56 | os.path.join(basedir, 'contrib', 'perf.py')) |
@@ -54,7 +54,7 b' try:' | |||
|
54 | 54 | sys.exit(0) |
|
55 | 55 | if len(args) != 3: |
|
56 | 56 | raise ParseError(_('wrong number of arguments')) |
|
57 | sys.exit(simplemerge.simplemerge(ui.ui(), *args, **opts)) | |
|
57 | sys.exit(simplemerge.simplemerge(ui.ui.load(), *args, **opts)) | |
|
58 | 58 | except ParseError as e: |
|
59 | 59 | sys.stdout.write("%s: %s\n" % (sys.argv[0], e)) |
|
60 | 60 | showhelp() |
@@ -158,7 +158,7 b' option.' | |||
|
158 | 158 | |
|
159 | 159 | (options, args) = optparser.parse_args() |
|
160 | 160 | |
|
161 | ui = uimod.ui() | |
|
161 | ui = uimod.ui.load() | |
|
162 | 162 | ui.setconfig('ui', 'verbose', options.verbose, '--verbose') |
|
163 | 163 | ui.setconfig('ui', 'debug', options.debug, '--debug') |
|
164 | 164 |
@@ -217,7 +217,7 b' if __name__ == "__main__":' | |||
|
217 | 217 | if len(sys.argv) > 1: |
|
218 | 218 | doc = sys.argv[1] |
|
219 | 219 | |
|
220 | ui = uimod.ui() | |
|
220 | ui = uimod.ui.load() | |
|
221 | 221 | if doc == 'hg.1.gendoc': |
|
222 | 222 | showdoc(ui) |
|
223 | 223 | else: |
@@ -101,7 +101,7 b' def dispatch(req):' | |||
|
101 | 101 | |
|
102 | 102 | try: |
|
103 | 103 | if not req.ui: |
|
104 | req.ui = uimod.ui() | |
|
104 | req.ui = uimod.ui.load() | |
|
105 | 105 | if '--traceback' in req.args: |
|
106 | 106 | req.ui.setconfig('ui', 'traceback', 'on', '--traceback') |
|
107 | 107 |
@@ -224,7 +224,7 b' class hgweb(object):' | |||
|
224 | 224 | if baseui: |
|
225 | 225 | u = baseui.copy() |
|
226 | 226 | else: |
|
227 | u = uimod.ui() | |
|
227 | u = uimod.ui.load() | |
|
228 | 228 | r = hg.repository(u, repo) |
|
229 | 229 | else: |
|
230 | 230 | # we trust caller to give us a private copy |
@@ -467,4 +467,3 b' def getwebview(repo):' | |||
|
467 | 467 | return repo.filtered(viewconfig) |
|
468 | 468 | else: |
|
469 | 469 | return repo.filtered('served') |
|
470 |
@@ -136,7 +136,7 b' class hgwebdir(object):' | |||
|
136 | 136 | if self.baseui: |
|
137 | 137 | u = self.baseui.copy() |
|
138 | 138 | else: |
|
139 | u = uimod.ui() | |
|
139 | u = uimod.ui.load() | |
|
140 | 140 | u.setconfig('ui', 'report_untrusted', 'off', 'hgwebdir') |
|
141 | 141 | u.setconfig('ui', 'nontty', 'true', 'hgwebdir') |
|
142 | 142 | # displaying bundling progress bar while serving feels wrong and may |
@@ -1302,7 +1302,7 b' def help(web, req, tmpl):' | |||
|
1302 | 1302 | return tmpl('helptopics', topics=topics, title=topicname, |
|
1303 | 1303 | subindex=True) |
|
1304 | 1304 | |
|
1305 | u = webutil.wsgiui() | |
|
1305 | u = webutil.wsgiui.load() | |
|
1306 | 1306 | u.verbose = True |
|
1307 | 1307 | |
|
1308 | 1308 | # Render a page from a sub-topic. |
@@ -96,6 +96,12 b' default = %s' | |||
|
96 | 96 | |
|
97 | 97 | class ui(object): |
|
98 | 98 | def __init__(self, src=None): |
|
99 | """Create a fresh new ui object if no src given | |
|
100 | ||
|
101 | Use uimod.ui.load() to create a ui which knows global and user configs. | |
|
102 | In most cases, you should use ui.copy() to create a copy of an existing | |
|
103 | ui object. | |
|
104 | """ | |
|
99 | 105 | # _buffers: used for temporary capture of output |
|
100 | 106 | self._buffers = [] |
|
101 | 107 | # 3-tuple describing how each buffer in the stack behaves. |
@@ -138,12 +144,18 b' class ui(object):' | |||
|
138 | 144 | |
|
139 | 145 | # shared read-only environment |
|
140 | 146 | self.environ = os.environ |
|
141 | # we always trust global config files | |
|
142 | for f in scmutil.rcpath(): | |
|
143 | self.readconfig(f, trust=True) | |
|
144 | 147 | |
|
145 | 148 | self.httppasswordmgrdb = urlreq.httppasswordmgrwithdefaultrealm() |
|
146 | 149 | |
|
150 | @classmethod | |
|
151 | def load(cls): | |
|
152 | """Create a ui and load global and user configs""" | |
|
153 | u = cls() | |
|
154 | # we always trust global config files | |
|
155 | for f in scmutil.rcpath(): | |
|
156 | u.readconfig(f, trust=True) | |
|
157 | return u | |
|
158 | ||
|
147 | 159 | def copy(self): |
|
148 | 160 | return self.__class__(self) |
|
149 | 161 |
@@ -37,7 +37,7 b' class dummysmtpsecureserver(dummysmtpser' | |||
|
37 | 37 | if not pair: |
|
38 | 38 | return |
|
39 | 39 | conn, addr = pair |
|
40 | ui = uimod.ui() | |
|
40 | ui = uimod.ui.load() | |
|
41 | 41 | try: |
|
42 | 42 | # wrap_socket() would block, but we don't care |
|
43 | 43 | conn = sslutil.wrapserversocket(conn, ui, certfile=self._certfile) |
@@ -449,7 +449,7 b' def has_sslcontext():' | |||
|
449 | 449 | @check("defaultcacerts", "can verify SSL certs by system's CA certs store") |
|
450 | 450 | def has_defaultcacerts(): |
|
451 | 451 | from mercurial import sslutil, ui as uimod |
|
452 | ui = uimod.ui() | |
|
452 | ui = uimod.ui.load() | |
|
453 | 453 | return sslutil._defaultcacerts(ui) or sslutil._canloaddefaultcerts |
|
454 | 454 | |
|
455 | 455 | @check("defaultcacertsloaded", "detected presence of loaded system CA certs") |
@@ -462,7 +462,7 b' def has_defaultcacertsloaded():' | |||
|
462 | 462 | if not has_sslcontext(): |
|
463 | 463 | return False |
|
464 | 464 | |
|
465 | ui = uimod.ui() | |
|
465 | ui = uimod.ui.load() | |
|
466 | 466 | cafile = sslutil._defaultcacerts(ui) |
|
467 | 467 | ctx = ssl.create_default_context() |
|
468 | 468 | if cafile: |
@@ -218,7 +218,7 b' dagtests = [' | |||
|
218 | 218 | '+3*3/*2*2/*4*4/*4/2*4/2*2', |
|
219 | 219 | ] |
|
220 | 220 | def test_gca(): |
|
221 | u = uimod.ui() | |
|
221 | u = uimod.ui.load() | |
|
222 | 222 | for i, dag in enumerate(dagtests): |
|
223 | 223 | repo = hg.repository(u, 'gca%d' % i, create=1) |
|
224 | 224 | cl = repo.changelog |
@@ -34,7 +34,7 b' Verify that updating to revision 0 via c' | |||
|
34 | 34 | |
|
35 | 35 | $ cat <<EOF > update_to_rev0.py |
|
36 | 36 | > from mercurial import ui, hg, commands |
|
37 | > myui = ui.ui() | |
|
37 | > myui = ui.ui.load() | |
|
38 | 38 | > repo = hg.repository(myui, path='.') |
|
39 | 39 | > commands.update(myui, repo, rev=0) |
|
40 | 40 | > EOF |
@@ -456,7 +456,7 b' test bisecting command' | |||
|
456 | 456 | > #!/usr/bin/env python |
|
457 | 457 | > import sys |
|
458 | 458 | > from mercurial import ui, hg |
|
459 | > repo = hg.repository(ui.ui(), '.') | |
|
459 | > repo = hg.repository(ui.ui.load(), '.') | |
|
460 | 460 | > if repo['.'].rev() < 6: |
|
461 | 461 | > sys.exit(1) |
|
462 | 462 | > EOF |
@@ -515,7 +515,7 b' iterable in addbranchrevs()' | |||
|
515 | 515 | |
|
516 | 516 | $ cat <<EOF > simpleclone.py |
|
517 | 517 | > from mercurial import ui, hg |
|
518 | > myui = ui.ui() | |
|
518 | > myui = ui.ui.load() | |
|
519 | 519 | > repo = hg.repository(myui, 'a') |
|
520 | 520 | > hg.clone(myui, {}, repo, dest="ua") |
|
521 | 521 | > EOF |
@@ -528,7 +528,7 b' iterable in addbranchrevs()' | |||
|
528 | 528 | |
|
529 | 529 | $ cat <<EOF > branchclone.py |
|
530 | 530 | > from mercurial import ui, hg, extensions |
|
531 | > myui = ui.ui() | |
|
531 | > myui = ui.ui.load() | |
|
532 | 532 | > extensions.loadall(myui) |
|
533 | 533 | > repo = hg.repository(myui, 'a') |
|
534 | 534 | > hg.clone(myui, {}, repo, dest="ua", branch=["stable",]) |
@@ -325,7 +325,7 b' The default interface is text' | |||
|
325 | 325 | $ chunkselectorinterface() { |
|
326 | 326 | > python <<EOF |
|
327 | 327 | > from mercurial import hg, ui, parsers;\ |
|
328 | > repo = hg.repository(ui.ui(), ".");\ | |
|
328 | > repo = hg.repository(ui.ui.load(), ".");\ | |
|
329 | 329 | > print repo.ui.interface("chunkselector") |
|
330 | 330 | > EOF |
|
331 | 331 | > } |
@@ -92,7 +92,7 b' now test that we fixed the bug for all s' | |||
|
92 | 92 | > def printfiles(repo, rev): |
|
93 | 93 | > print "revision %s files: %s" % (rev, repo[rev].files()) |
|
94 | 94 | > |
|
95 | > repo = hg.repository(ui.ui(), '.') | |
|
95 | > repo = hg.repository(ui.ui.load(), '.') | |
|
96 | 96 | > assert len(repo) == 6, \ |
|
97 | 97 | > "initial: len(repo): %d, expected: 6" % len(repo) |
|
98 | 98 | > |
@@ -609,7 +609,7 b' verify pathauditor blocks evil filepaths' | |||
|
609 | 609 | $ cat > evil-commit.py <<EOF |
|
610 | 610 | > from mercurial import ui, hg, context, node |
|
611 | 611 | > notrc = u".h\u200cg".encode('utf-8') + '/hgrc' |
|
612 | > u = ui.ui() | |
|
612 | > u = ui.ui.load() | |
|
613 | 613 | > r = hg.repository(u, '.') |
|
614 | 614 | > def filectxfn(repo, memctx, path): |
|
615 | 615 | > return context.memfilectx(repo, path, '[hooks]\nupdate = echo owned') |
@@ -633,7 +633,7 b' verify pathauditor blocks evil filepaths' | |||
|
633 | 633 | $ cat > evil-commit.py <<EOF |
|
634 | 634 | > from mercurial import ui, hg, context, node |
|
635 | 635 | > notrc = "HG~1/hgrc" |
|
636 | > u = ui.ui() | |
|
636 | > u = ui.ui.load() | |
|
637 | 637 | > r = hg.repository(u, '.') |
|
638 | 638 | > def filectxfn(repo, memctx, path): |
|
639 | 639 | > return context.memfilectx(repo, path, '[hooks]\nupdate = echo owned') |
@@ -651,7 +651,7 b' verify pathauditor blocks evil filepaths' | |||
|
651 | 651 | $ cat > evil-commit.py <<EOF |
|
652 | 652 | > from mercurial import ui, hg, context, node |
|
653 | 653 | > notrc = "HG8B6C~2/hgrc" |
|
654 | > u = ui.ui() | |
|
654 | > u = ui.ui.load() | |
|
655 | 655 | > r = hg.repository(u, '.') |
|
656 | 656 | > def filectxfn(repo, memctx, path): |
|
657 | 657 | > return context.memfilectx(repo, path, '[hooks]\nupdate = echo owned') |
@@ -7,7 +7,7 b' from mercurial import (' | |||
|
7 | 7 | ui as uimod, |
|
8 | 8 | ) |
|
9 | 9 | |
|
10 | u = uimod.ui() | |
|
10 | u = uimod.ui.load() | |
|
11 | 11 | |
|
12 | 12 | repo = hg.repository(u, 'test1', create=1) |
|
13 | 13 | os.chdir('test1') |
@@ -21,7 +21,7 b' for ext in disabled:' | |||
|
21 | 21 | |
|
22 | 22 | hgrc.close() |
|
23 | 23 | |
|
24 | u = uimod.ui() | |
|
24 | u = uimod.ui.load() | |
|
25 | 25 | extensions.loadall(u) |
|
26 | 26 | |
|
27 | 27 | globalshort = set() |
@@ -141,7 +141,7 b' def fakeuncacheable():' | |||
|
141 | 141 | def test_filecache_synced(): |
|
142 | 142 | # test old behavior that caused filecached properties to go out of sync |
|
143 | 143 | os.system('hg init && echo a >> a && hg ci -qAm.') |
|
144 | repo = hg.repository(uimod.ui()) | |
|
144 | repo = hg.repository(uimod.ui.load()) | |
|
145 | 145 | # first rollback clears the filecache, but changelog to stays in __dict__ |
|
146 | 146 | repo.rollback() |
|
147 | 147 | repo.commit('.') |
@@ -13,7 +13,7 b' from mercurial import (' | |||
|
13 | 13 | ui as uimod, |
|
14 | 14 | ) |
|
15 | 15 | |
|
16 | myui = uimod.ui() | |
|
16 | myui = uimod.ui.load() | |
|
17 | 17 | repo = hg.repository(myui, path='.', create=True) |
|
18 | 18 | |
|
19 | 19 | fl = repo.file('foobar') |
@@ -15,7 +15,7 b' class myui(uimod.ui):' | |||
|
15 | 15 | def interactive(self): |
|
16 | 16 | return False |
|
17 | 17 | |
|
18 | origui = myui() | |
|
18 | origui = myui.load() | |
|
19 | 19 | |
|
20 | 20 | def writeauth(items): |
|
21 | 21 | ui = origui.copy() |
@@ -15,7 +15,7 b" os.chdir('webdir')" | |||
|
15 | 15 | |
|
16 | 16 | webdir = os.path.realpath('.') |
|
17 | 17 | |
|
18 | u = uimod.ui() | |
|
18 | u = uimod.ui.load() | |
|
19 | 19 | hg.repository(u, 'a', create=1) |
|
20 | 20 | hg.repository(u, 'b', create=1) |
|
21 | 21 | os.chdir('b') |
@@ -81,7 +81,7 b' verify 7e7d56fe4833 (encoding fallback i' | |||
|
81 | 81 | > sys.stdout = StdoutWrapper(sys.stdout) |
|
82 | 82 | > sys.stderr = StdoutWrapper(sys.stderr) |
|
83 | 83 | > |
|
84 | > myui = ui.ui() | |
|
84 | > myui = ui.ui.load() | |
|
85 | 85 | > repo = hg.repository(myui, 'a') |
|
86 | 86 | > commands.serve(myui, repo, stdio=True, cmdserver=False) |
|
87 | 87 | > EOF |
@@ -46,7 +46,7 b' localrepo.localrepository.testcachedunfi' | |||
|
46 | 46 | # these tests on the real object to detect regression. |
|
47 | 47 | repopath = os.path.join(os.environ['TESTTMP'], 'repo') |
|
48 | 48 | assert subprocess.call(['hg', 'init', repopath]) == 0 |
|
49 | ui = uimod.ui() | |
|
49 | ui = uimod.ui.load() | |
|
50 | 50 | repo = hg.repository(ui, path=repopath).unfiltered() |
|
51 | 51 | |
|
52 | 52 |
@@ -6,7 +6,7 b' from mercurial import (' | |||
|
6 | 6 | ui as uimod, |
|
7 | 7 | ) |
|
8 | 8 | |
|
9 | u = uimod.ui() | |
|
9 | u = uimod.ui.load() | |
|
10 | 10 | |
|
11 | 11 | repo = hg.repository(u, 'test1', create=1) |
|
12 | 12 | os.chdir('test1') |
@@ -7,7 +7,7 b' from mercurial import (' | |||
|
7 | 7 | ui as uimod, |
|
8 | 8 | ) |
|
9 | 9 | |
|
10 | u = uimod.ui() | |
|
10 | u = uimod.ui.load() | |
|
11 | 11 | |
|
12 | 12 | print('% creating repo') |
|
13 | 13 | repo = localrepo.localrepository(u, '.', create=True) |
@@ -17,7 +17,7 b" BUNDLEPATH = os.path.join(TESTDIR, 'bund" | |||
|
17 | 17 | if not getattr(os, "symlink", False): |
|
18 | 18 | sys.exit(80) # SKIPPED_STATUS defined in run-tests.py |
|
19 | 19 | |
|
20 | u = uimod.ui() | |
|
20 | u = uimod.ui.load() | |
|
21 | 21 | # hide outer repo |
|
22 | 22 | hg.peer(u, {}, '.', create=True) |
|
23 | 23 | |
@@ -48,10 +48,10 b" for f in 'test0/a.lnk', 'test0/d/b.lnk':" | |||
|
48 | 48 | fp.close() |
|
49 | 49 | |
|
50 | 50 | # reload repository |
|
51 | u = uimod.ui() | |
|
51 | u = uimod.ui.load() | |
|
52 | 52 | repo = hg.repository(u, 'test0') |
|
53 | 53 | commands.status(u, repo) |
|
54 | 54 | |
|
55 | 55 | # try cloning a repo which contains symlinks |
|
56 | u = uimod.ui() | |
|
56 | u = uimod.ui.load() | |
|
57 | 57 | hg.clone(u, {}, BUNDLEPATH, 'test1') |
@@ -66,7 +66,7 b" def testui(user='foo', group='bar', tuse" | |||
|
66 | 66 | print('# %s user, %s group%s' % (kind[user == cuser], kind[group == cgroup], |
|
67 | 67 | trusted)) |
|
68 | 68 | |
|
69 | u = uimod.ui() | |
|
69 | u = uimod.ui.load() | |
|
70 | 70 | u.setconfig('ui', 'debug', str(bool(debug))) |
|
71 | 71 | u.setconfig('ui', 'report_untrusted', str(bool(report))) |
|
72 | 72 | u.readconfig('.hg/hgrc') |
@@ -156,7 +156,7 b" print(u.config('foobar', 'baz'))" | |||
|
156 | 156 | |
|
157 | 157 | print() |
|
158 | 158 | print("# read trusted, untrusted, new ui, trusted") |
|
159 | u = uimod.ui() | |
|
159 | u = uimod.ui.load() | |
|
160 | 160 | u.setconfig('ui', 'debug', 'on') |
|
161 | 161 | u.readconfig(filename) |
|
162 | 162 | u2 = u.copy() |
@@ -23,7 +23,7 b" hgrc.write('[extensions]\\n')" | |||
|
23 | 23 | hgrc.write('color=\n') |
|
24 | 24 | hgrc.close() |
|
25 | 25 | |
|
26 | ui_ = uimod.ui() | |
|
26 | ui_ = uimod.ui.load() | |
|
27 | 27 | ui_.setconfig('ui', 'formatted', 'True') |
|
28 | 28 | |
|
29 | 29 | # we're not interested in the output, so write that to devnull |
@@ -5,7 +5,7 b' from mercurial import (' | |||
|
5 | 5 | ui as uimod, |
|
6 | 6 | ) |
|
7 | 7 | |
|
8 | testui = uimod.ui() | |
|
8 | testui = uimod.ui.load() | |
|
9 | 9 | parsed = dispatch._parseconfig(testui, [ |
|
10 | 10 | 'values.string=string value', |
|
11 | 11 | 'values.bool1=true', |
General Comments 0
You need to be logged in to leave comments.
Login now