[PATCH] add color diff support to record extension

Brodie Rao dackze at gmail.com
Thu Aug 13 12:03:44 CDT 2009


On Aug 10, 2009, at 4:35 AM, Dirkjan Ochtman wrote:

> On Mon, Aug 10, 2009 at 10:24, TK Soh<teekaysoh at gmail.com> wrote:
>> BTW, I started thinking about this when trying to add the color diff
>> support into the hgshelve extension: "should the [mq] extension be
>> requesting for the color support, instead of color extension forcing
>> it into the [mq] extensions?"
>>
>> To me the former more 'natural', and it would also make it easier to
>> enable color support for third-party extensions like hgshelve. Though
>> the color extension will need to provide the public interface to
>> support that.
>
> For most stuff we have now, it seems the implementation burden for
> coloring output falls squarely in the color extension. If that's a
> valid assumption, then it makes much more sense to me to have color
> "support" shelve than for shelve to "request" color. Brodie might have
> a different idea though, so I'd like to know what he thinks. (And I
> think either way could use an extension hooking mechanism.)

I think moving color into ui is the most obvious choice. I think Dan's  
idea of augmenting ui.write() to emit colors is good.

I haven't had a chance to look into it deeply, but I imagine you'd  
need to do the following things:

1. Take color's smart terminal detection and make sure ui can do the  
same.

2. Make --color and --no-color global options. (I'd really like to get  
rid of --no-color, though.)

3. Implement something like ui.write(..., color=True).

#3 raises a couple of questions:

* How are colors inserted? Templates? %-style expansion?

* How do users of the new API (hg diff, hg qseries, etc.) specify what  
color keys are available and what their default colors are?


More information about the Mercurial-devel mailing list