comparison hgext/color.py @ 14516:842a9179132c

color: check if ui is already a subclass of colorui before wrapping it since it's possible to reuse the ui object (see 80c599eee3f3) between dispatch calls, the ui might have been wrapped already. we could probably move this test up a bit but leaving it here allows updates to take effect by extstyles() and configstyles().
author Idan Kamara <idankk86@gmail.com>
date Thu, 02 Jun 2011 00:43:34 +0300
parents ad6ad51cc0dd
children 1e6661e09818
comparison
equal deleted inserted replaced
14515:76f295eaed86 14516:842a9179132c
347 return 347 return
348 def colorcmd(orig, ui_, opts, cmd, cmdfunc): 348 def colorcmd(orig, ui_, opts, cmd, cmdfunc):
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)
357 extensions.wrapfunction(dispatch, '_runcommand', colorcmd) 358 extensions.wrapfunction(dispatch, '_runcommand', colorcmd)
358 359