equal
deleted
inserted
replaced
3 import os |
3 import os |
4 from mercurial import ( |
4 from mercurial import ( |
5 dispatch, |
5 dispatch, |
6 ui as uimod, |
6 ui as uimod, |
7 ) |
7 ) |
8 from mercurial.utils import ( |
8 from mercurial.utils import stringutil |
9 stringutil, |
|
10 ) |
|
11 |
9 |
12 # ensure errors aren't buffered |
10 # ensure errors aren't buffered |
13 testui = uimod.ui() |
11 testui = uimod.ui() |
14 testui.pushbuffer() |
12 testui.pushbuffer() |
15 testui.write((b'buffered\n')) |
13 testui.write(b'buffered\n') |
16 testui.warn((b'warning\n')) |
14 testui.warn(b'warning\n') |
17 testui.write_err(b'error\n') |
15 testui.write_err(b'error\n') |
18 print(stringutil.pprint(testui.popbuffer(), bprefix=True).decode('ascii')) |
16 print(stringutil.pprint(testui.popbuffer(), bprefix=True).decode('ascii')) |
19 |
17 |
20 # test dispatch.dispatch with the same ui object |
18 # test dispatch.dispatch with the same ui object |
21 hgrc = open(os.environ["HGRCPATH"], 'wb') |
19 hgrc = open(os.environ["HGRCPATH"], 'wb') |
32 # call some arbitrary command just so we go through |
30 # call some arbitrary command just so we go through |
33 # color's wrapped _runcommand twice. |
31 # color's wrapped _runcommand twice. |
34 def runcmd(): |
32 def runcmd(): |
35 dispatch.dispatch(dispatch.request([b'version', b'-q'], ui_)) |
33 dispatch.dispatch(dispatch.request([b'version', b'-q'], ui_)) |
36 |
34 |
|
35 |
37 runcmd() |
36 runcmd() |
38 print("colored? %s" % (ui_._colormode is not None)) |
37 print("colored? %s" % (ui_._colormode is not None)) |
39 runcmd() |
38 runcmd() |
40 print("colored? %s" % (ui_._colormode is not None)) |
39 print("colored? %s" % (ui_._colormode is not None)) |