Patchwork [2,of,2,V4] color: fallback and test label as an effect

login
register
mail settings
Submitter Sean Farley
Date April 7, 2014, 11:20 p.m.
Message ID <c3f05ce58c1a48c70a6d.1396912801@laptop.local>
Download mbox | patch
Permalink /patch/4269/
State Accepted
Commit a8db48e997b57c64aa646ec2762e37bbc7a17482
Headers show

Comments

Sean Farley - April 7, 2014, 11:20 p.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1396903047 18000
#      Mon Apr 07 15:37:27 2014 -0500
# Node ID c3f05ce58c1a48c70a6d998a6fe64533a28fb262
# Parent  fe252f8b05c6a0e3b3ad4ed54d90c5bac07c0d6b
color: fallback and test label as an effect

With this changeset, we can now send a color name directly to the label
function, e.g.

$ hg log -r . -T "{label('red', node|short)}\n"
Matt Mackall - April 11, 2014, 10:02 p.m.
On Mon, 2014-04-07 at 18:20 -0500, Sean Farley wrote:
> # HG changeset patch
> # User Sean Farley <sean.michael.farley@gmail.com>
> # Date 1396903047 18000
> #      Mon Apr 07 15:37:27 2014 -0500
> # Node ID c3f05ce58c1a48c70a6d998a6fe64533a28fb262
> # Parent  fe252f8b05c6a0e3b3ad4ed54d90c5bac07c0d6b
> color: fallback and test label as an effect
> 
> With this changeset, we can now send a color name directly to the label
> function, e.g.
> 
> $ hg log -r . -T "{label('red', node|short)}\n"

These are queued for default, thanks. It'd be nice if we could figure
out how to drop the need to quote 'red' here.
Sean Farley - April 11, 2014, 11:55 p.m.
Matt Mackall <mpm@selenic.com> writes:

> On Mon, 2014-04-07 at 18:20 -0500, Sean Farley wrote:
>> # HG changeset patch
>> # User Sean Farley <sean.michael.farley@gmail.com>
>> # Date 1396903047 18000
>> #      Mon Apr 07 15:37:27 2014 -0500
>> # Node ID c3f05ce58c1a48c70a6d998a6fe64533a28fb262
>> # Parent  fe252f8b05c6a0e3b3ad4ed54d90c5bac07c0d6b
>> color: fallback and test label as an effect
>> 
>> With this changeset, we can now send a color name directly to the label
>> function, e.g.
>> 
>> $ hg log -r . -T "{label('red', node|short)}\n"
>
> These are queued for default, thanks. It'd be nice if we could figure
> out how to drop the need to quote 'red' here.

I agree. I'll try to whip something up.

Patch

diff --git a/hgext/color.py b/hgext/color.py
--- a/hgext/color.py
+++ b/hgext/color.py
@@ -380,10 +380,12 @@  class colorui(uimod.ui):
         effects = []
         for l in label.split():
             s = _styles.get(l, '')
             if s:
                 effects.append(s)
+            elif valideffect(l):
+                effects.append(l)
         effects = ' '.join(effects)
         if effects:
             return '\n'.join([render_effects(s, effects)
                               for s in msg.split('\n')])
         return msg