Patchwork [3,of,5] color: extract color and effect display from 'debugcolor'

login
register
mail settings
Submitter Pierre-Yves David
Date Nov. 3, 2016, 3:56 p.m.
Message ID <a426f9f5c76af2ae9450.1478188594@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/17318/
State Accepted
Headers show

Comments

Pierre-Yves David - Nov. 3, 2016, 3:56 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1478180927 -3600
#      Thu Nov 03 14:48:47 2016 +0100
# Node ID a426f9f5c76af2ae94500d9a4c845a5d12b27bbc
# Parent  d2f98dbce59c7f0cfa8856ead06ad59985e23332
# EXP-Topic debugcolor
color: extract color and effect display from 'debugcolor'

We are about to introduce a second mode for 'hg debugcolor' that would list the
known label and their configuration, so we split the code related to color and
effect out of the main function.

Patch

diff --git a/hgext/color.py b/hgext/color.py
--- a/hgext/color.py
+++ b/hgext/color.py
@@ -539,6 +539,10 @@  def extsetup(ui):
 @command('debugcolor', [], 'hg debugcolor')
 def debugcolor(ui, repo, **opts):
     """show available colors and effects"""
+    ui.write(('color mode: %s\n') % ui._colormode)
+    return _debugdisplaycolor(ui)
+
+def _debugdisplaycolor(ui):
     global _styles
     oldstyle = _styles
     try:
@@ -551,7 +555,6 @@  def debugcolor(ui, repo, **opts):
                     _styles[k] = k[6:]
                 elif k.startswith('terminfo.'):
                     _styles[k] = k[9:]
-        ui.write(('color mode: %s\n') % ui._colormode)
         ui.write(_('available colors:\n'))
         for colorname, label in _styles.items():
             ui.write(('%s\n') % colorname, label=label)