Patchwork [13,of,13,V2] color: drop the 'colorui' class

login
register
mail settings
Submitter Pierre-Yves David
Date Feb. 24, 2017, 10:09 p.m.
Message ID <07fe8ac5a9038dece502.1487974187@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/18766/
State Accepted
Headers show

Comments

Pierre-Yves David - Feb. 24, 2017, 10:09 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1487590955 -3600
#      Mon Feb 20 12:42:35 2017 +0100
# Node ID 07fe8ac5a9038dece502507af9e59728a6a8c13a
# Parent  419d5f42cc7b764f5304b2518146824329c32f91
# EXP-Topic color
color: drop the 'colorui' class

Now that all logics formally bared by 'colorui' have been moved to the main ui
class, that class is empty and can be dropped. As a nice side effect we can get
rid of the baroque Initialization associated to it.

There was much rejoicing.
Durham Goode - Feb. 24, 2017, 11:08 p.m.
On 2/24/17 2:09 PM, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
> # Date 1487590955 -3600
> #      Mon Feb 20 12:42:35 2017 +0100
> # Node ID 07fe8ac5a9038dece502507af9e59728a6a8c13a
> # Parent  419d5f42cc7b764f5304b2518146824329c32f91
> # EXP-Topic color
> color: drop the 'colorui' class
>
> Now that all logics formally bared by 'colorui' have been moved to the main ui
> class, that class is empty and can be dropped. As a nice side effect we can get
> rid of the baroque Initialization associated to it.
>
> There was much rejoicing.


This series looks good to me, from a correctness stand point.  There's a 
few grammar spots, but not enough to require fixing I think.
Yuya Nishihara - Feb. 25, 2017, 5:23 a.m.
On Fri, 24 Feb 2017 15:08:35 -0800, Durham Goode wrote:
> On 2/24/17 2:09 PM, Pierre-Yves David wrote:
> > # HG changeset patch
> > # User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
> > # Date 1487590955 -3600
> > #      Mon Feb 20 12:42:35 2017 +0100
> > # Node ID 07fe8ac5a9038dece502507af9e59728a6a8c13a
> > # Parent  419d5f42cc7b764f5304b2518146824329c32f91
> > # EXP-Topic color
> > color: drop the 'colorui' class
> >
> > Now that all logics formally bared by 'colorui' have been moved to the main ui
> > class, that class is empty and can be dropped. As a nice side effect we can get
> > rid of the baroque Initialization associated to it.
> >
> > There was much rejoicing.
> 
> 
> This series looks good to me, from a correctness stand point.  There's a 
> few grammar spots, but not enough to require fixing I think.

Yeah, queued with some grammar fixes and trivial whitespace changes spotted by
flake8. Thanks!

Patch

diff -r 419d5f42cc7b -r 07fe8ac5a903 hgext/color.py
--- a/hgext/color.py	Mon Feb 20 12:42:23 2017 +0100
+++ b/hgext/color.py	Mon Feb 20 12:42:35 2017 +0100
@@ -296,18 +296,12 @@  def _modesetup(ui, coloropt):
         return realmode
     return None
 
-class colorui(uimod.ui):
-    pass
-
 def uisetup(ui):
     if ui.plain():
         return
-    if not isinstance(ui, colorui):
-        colorui.__bases__ = (ui.__class__,)
-        ui.__class__ = colorui
     def colorcmd(orig, ui_, opts, cmd, cmdfunc):
         mode = _modesetup(ui_, opts['color'])
-        colorui._colormode = mode
+        uimod.ui._colormode = mode
         if mode and mode != 'debug':
             color.configstyles(ui_)
         return orig(ui_, opts, cmd, cmdfunc)
diff -r 419d5f42cc7b -r 07fe8ac5a903 tests/test-ui-color.py
--- a/tests/test-ui-color.py	Mon Feb 20 12:42:23 2017 +0100
+++ b/tests/test-ui-color.py	Mon Feb 20 12:42:35 2017 +0100
@@ -1,16 +1,13 @@ 
 from __future__ import absolute_import, print_function
 
 import os
-from hgext import (
-    color,
-)
 from mercurial import (
     dispatch,
     ui as uimod,
 )
 
 # ensure errors aren't buffered
-testui = color.colorui()
+testui = uimod.ui()
 testui.pushbuffer()
 testui.write(('buffered\n'))
 testui.warn(('warning\n'))
@@ -35,6 +32,7 @@  def runcmd():
     dispatch.dispatch(dispatch.request(['version', '-q'], ui_))
 
 runcmd()
-print("colored? " + str(issubclass(ui_.__class__, color.colorui)))
+print("colored? %s" % (ui_._colormode is not None))
 runcmd()
-print("colored? " + str(issubclass(ui_.__class__, color.colorui)))
+print("colored? %s" % (ui_._colormode is not None))
+