From d254535be603eb389e4da722be8bae292c2602a2 Mon Sep 17 00:00:00 2001 From: Pierre-Yves David Date: Thu, 3 Nov 2016 14:48:47 +0100 Subject: [PATCH] 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. --- hgext/color.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hgext/color.py b/hgext/color.py index 68060d5a19..2b82fb823f 100644 --- 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)