##// END OF EJS Templates
color: check if ui is already a subclass of colorui before wrapping it...
Idan Kamara -
r14516:842a9179 default
parent child Browse files
Show More
@@ -349,8 +349,9 b' def uisetup(ui):'
349 mode = _modesetup(ui_, opts)
349 mode = _modesetup(ui_, opts)
350 if mode:
350 if mode:
351 colorui._colormode = mode
351 colorui._colormode = mode
352 colorui.__bases__ = (ui_.__class__,)
352 if not issubclass(ui_.__class__, colorui):
353 ui_.__class__ = colorui
353 colorui.__bases__ = (ui_.__class__,)
354 ui_.__class__ = colorui
354 extstyles()
355 extstyles()
355 configstyles(ui_)
356 configstyles(ui_)
356 return orig(ui_, opts, cmd, cmdfunc)
357 return orig(ui_, opts, cmd, cmdfunc)
@@ -1,4 +1,6 b''
1 import os, sys
1 from hgext import color
2 from hgext import color
3 from mercurial import dispatch, ui
2
4
3 # ensure errors aren't buffered
5 # ensure errors aren't buffered
4 testui = color.colorui()
6 testui = color.colorui()
@@ -7,3 +9,25 b" testui.write('buffered\\n')"
7 testui.warn('warning\n')
9 testui.warn('warning\n')
8 testui.write_err('error\n')
10 testui.write_err('error\n')
9 print repr(testui.popbuffer())
11 print repr(testui.popbuffer())
12
13 # test dispatch.dispatch with the same ui object
14 hgrc = open(os.environ["HGRCPATH"], 'w')
15 hgrc.write('[extensions]\n')
16 hgrc.write('color=\n')
17 hgrc.close()
18
19 ui_ = ui.ui()
20 ui_.setconfig('ui', 'formatted', 'True')
21
22 # call some arbitrary command just so we go through
23 # color's wrapped _runcommand twice.
24 # we're not interested in the output, so write that to devnull
25 def runcmd():
26 sys.stdout = open(os.devnull, 'w')
27 dispatch.dispatch(dispatch.request(['version', '-q'], ui_))
28 sys.stdout = sys.__stdout__
29
30 runcmd()
31 print "colored? " + str(issubclass(ui_.__class__, color.colorui))
32 runcmd()
33 print "colored? " + str(issubclass(ui_.__class__, color.colorui))
@@ -1,3 +1,5 b''
1 warning
1 warning
2 error
2 error
3 'buffered\n'
3 'buffered\n'
4 colored? True
5 colored? True
General Comments 0
You need to be logged in to leave comments. Login now