[PATCH 3 of 6] move: move the 'label' method to the core class

Yuya Nishihara yuya at tcha.org
Thu Feb 23 09:09:50 EST 2017


On Wed, 22 Feb 2017 17:54:34 +0100, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
> # Date 1487590284 -3600
> #      Mon Feb 20 12:31:24 2017 +0100
> # Node ID 9a9e8b28b717e30ed43030cc64f115a4356193de
> # Parent  f53e95ec986616a48a3a8e67e5a9674b8a684d6e
> # EXP-Topic color
> move: move the 'label' method to the core class
> 
> We move 'label' method from the custom 'colorui' class to the core 'ui' class.
> This bring us closer to supporting color in core natively. Core already have a
> 'label' method that was a no-op. We update its content with the logic from the
> extension. Behavior is unchanged when colormode = None.

It's nice to move color functions into core and get rid of the colorui class,
but I also think we should avoid making ui.py bloated. So, instead of moving
everything into ui.py, can we put them in color.py as module-level functions?

For instance,

  def label(self, msg, label):
      if self._colormode:
          msg = color.labeledstr(self._colormode, msg, label)
      return msg

  def write(self, *args, **opts):
      ...
      if self._colormode:
          color.writelabeled(self._colormode, self.fout, *args, **opts)


More information about the Mercurial-devel mailing list