Show More
@@ -296,18 +296,12 b' def _modesetup(ui, coloropt):' | |||||
296 | return realmode |
|
296 | return realmode | |
297 | return None |
|
297 | return None | |
298 |
|
298 | |||
299 | class colorui(uimod.ui): |
|
|||
300 | pass |
|
|||
301 |
|
||||
302 | def uisetup(ui): |
|
299 | def uisetup(ui): | |
303 | if ui.plain(): |
|
300 | if ui.plain(): | |
304 | return |
|
301 | return | |
305 | if not isinstance(ui, colorui): |
|
|||
306 | colorui.__bases__ = (ui.__class__,) |
|
|||
307 | ui.__class__ = colorui |
|
|||
308 | def colorcmd(orig, ui_, opts, cmd, cmdfunc): |
|
302 | def colorcmd(orig, ui_, opts, cmd, cmdfunc): | |
309 | mode = _modesetup(ui_, opts['color']) |
|
303 | mode = _modesetup(ui_, opts['color']) | |
310 |
|
|
304 | uimod.ui._colormode = mode | |
311 | if mode and mode != 'debug': |
|
305 | if mode and mode != 'debug': | |
312 | color.configstyles(ui_) |
|
306 | color.configstyles(ui_) | |
313 | return orig(ui_, opts, cmd, cmdfunc) |
|
307 | return orig(ui_, opts, cmd, cmdfunc) |
@@ -1,16 +1,13 b'' | |||||
1 | from __future__ import absolute_import, print_function |
|
1 | from __future__ import absolute_import, print_function | |
2 |
|
2 | |||
3 | import os |
|
3 | import os | |
4 | from hgext import ( |
|
|||
5 | color, |
|
|||
6 | ) |
|
|||
7 | from mercurial import ( |
|
4 | from mercurial import ( | |
8 | dispatch, |
|
5 | dispatch, | |
9 | ui as uimod, |
|
6 | ui as uimod, | |
10 | ) |
|
7 | ) | |
11 |
|
8 | |||
12 | # ensure errors aren't buffered |
|
9 | # ensure errors aren't buffered | |
13 |
testui = |
|
10 | testui = uimod.ui() | |
14 | testui.pushbuffer() |
|
11 | testui.pushbuffer() | |
15 | testui.write(('buffered\n')) |
|
12 | testui.write(('buffered\n')) | |
16 | testui.warn(('warning\n')) |
|
13 | testui.warn(('warning\n')) | |
@@ -35,6 +32,7 b' def runcmd():' | |||||
35 | dispatch.dispatch(dispatch.request(['version', '-q'], ui_)) |
|
32 | dispatch.dispatch(dispatch.request(['version', '-q'], ui_)) | |
36 |
|
33 | |||
37 | runcmd() |
|
34 | runcmd() | |
38 | print("colored? " + str(issubclass(ui_.__class__, color.colorui))) |
|
35 | print("colored? %s" % (ui_._colormode is not None)) | |
39 | runcmd() |
|
36 | runcmd() | |
40 | print("colored? " + str(issubclass(ui_.__class__, color.colorui))) |
|
37 | print("colored? %s" % (ui_._colormode is not None)) | |
|
38 |
General Comments 0
You need to be logged in to leave comments.
Login now