Merge lp://qastaging/~benoit.pierre/bzrtools/colordiff_when_tty into lp://qastaging/bzrtools

Proposed by Benoit Pierre
Status: Merged
Merged at revision: not available
Proposed branch: lp://qastaging/~benoit.pierre/bzrtools/colordiff_when_tty
Merge into: lp://qastaging/bzrtools
To merge this branch: bzr merge lp://qastaging/~benoit.pierre/bzrtools/colordiff_when_tty
Reviewer Review Type Date Requested Status
Aaron Bentley Needs Resubmitting
Review via email: mp+1732@code.qastaging.launchpad.net
To post a comment you must log in.
Revision history for this message
Benoit Pierre (benoit.pierre) wrote :

Only colorize output in colordiff if terminal support it: fix has_ansi_colors to check if STDOUT is a TTY, and use it in colordiff. This allows one to alias diff to cdiff and always use it even when redirecting outpout to a file or a pager.

Revision history for this message
Aaron Bentley (abentley) wrote :

I do want cdiff to colorize diffs when it is piped into a pager, because less -R does a great job of handling colorized diffs. This is also explained in bug #242115.

review: Needs Resubmitting
Revision history for this message
Benoit Pierre (benoit.pierre) wrote :

OK, so how about a --color option that works like for ls:

# ls --color=never
-> no colors
# ls --color=never > listing
-> no colors
# ls --color=auto
-> colors
# ls --color=auto > listing
-> no colors
# ls --color=always
-> colors
# ls --color=always > listing
-> colors

'auto' being the default mode.

Revision history for this message
Aaron Bentley (abentley) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Benoit PIERRE wrote:
> OK, so how about a --color option that works like for ls:

Sure. You'll probably want to use
bzrlib.option.RegistryOption.from_kwargs for that.

It seems weird to support color=never, since that's diff, but I can see
it might be useful for overriding color display in a cdiff alias.

> 'auto' being the default mode.

Because we're talking about cdiff, I think the best default is 'always'.
 After all, you're executing a command whose reason for existence is
providing colour output. That's even part of its name.

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkkhgr8ACgkQ0F+nu1YWqI07rgCfeGCjq9LDB8XEv/64QXmHlyu1
mggAnRSk4iTDW7jKeaZTHvd39IabQfbX
=FZGK
-----END PGP SIGNATURE-----

683. By Benoit Pierre

Add --color=MODE option to cdiff; MODE can be:
* never: never colorize output
* auto: colorize output if terminal supports it, and STDOUT is a TTY
* always: always colorize ouput (default)

Revision history for this message
Benoit Pierre (benoit.pierre) wrote :

OK, done, cdiff can now take a --color option:

  --color=ARG Color mode to use. "auto": Only colorize output if
                                  terminal supports it and STDOUT is a TTY. "never":
                                  Never colorize output. "always": Always colorize
                                  ouput (default).

I tested it on Linux and Windows (in a regular command prompt and with a cygwin shell).

Revision history for this message
Aaron Bentley (abentley) wrote :

I have merged this, and fixed it so that supplying --color=never only disables colour, not style checks.

Subscribers

People subscribed via source and target branches