Use color on 'status' and 'qseries' output

Matt Mackall mpm at selenic.com
Thu Dec 27 19:34:22 CST 2007


On Thu, 2007-12-27 at 18:26 -0600, Kevin Christen wrote:
> I've put together the attached patch to use different colors for
> different file statuses on the 'status' command, and to differentiate
> between applied and unapplied patches on the 'qseries' command.  I
> implemented this as changes to the existing commands rather than
> extensions because: 
>       * Extensions would have required copy and pasting large chunks
>         of mercurial.hg.status and hgext.mq.queue.qseries, and I hate
>         cut and paste coding.
>       * Parallel command sets don't seem like a very good idea as the
>         number of commands grows ('diff' and 'cdiff', 'status' and
>         'cstatus', 'qseries' and 'cqseries', ...)
> I'd appreciate feedback on these (and any other) questions:
>       * Do you find this useful?
>       * What other commands might benefit from this treatment?
>       * Has any thought been given to changing the alias extension to
>         allow aliasing of built-in commands (alias diff=cdiff).  That
>         would address the issue of parallel command sets.
>       * How's my python?  I'm fairly new to the language.

Unfortunately, I'm not much of a fan of colored console output.

I think it is possible to do this reasonably in an extension. Here's how
you might do that for status:

- wrap commands.status with a new command
- divert the ui output with ui.pushbuffer
- run the original status command
- pop the output into a string with ui.popbuffer
- colorize it with regexes
- write it with ui.write

-- 
Mathematics is the supreme nostalgia of our time.



More information about the Mercurial-devel mailing list