colored diff

Asked by Lucius

How do a I do colored diff? bzr diff just prints out the human-unreadable diff notation. I found one plugin that allows to pipe the bzr diff output to any third party diff tool.

This is a great idea and should be part of bazaar core functionality (instead of a plugin), but for some strange reasons the diff plugin accomplishes this by copying huge amount of files into a temp location, which slows down performance too much.

Thanks a lot for any tip.

-Lucius

Question information

Language:
English Edit question
Status:
Expired
For:
Bazaar Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Elliot Murphy (statik) said :
#1

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

On 06/20/2007 02:04 AM, Lucius wrote:
> New question #8468 on Bazaar:
> https://answers.launchpad.net/bzr/+question/8468
>
> How do a I do colored diff? bzr diff just prints out the human-unreadable diff notation. I found one plugin that allows to pipe the bzr diff output to any third party diff tool.

Hi Lucius,

I personally use the 'cdiff' command which is added by the bzrtools
plugin. There is also a program (not associated with Bazaar) called
colordiff, which you can pipe any diff to and the diff will be colored.

So,

- - bzr cdiff
or
- - bzr diff | colordiff

depending on your preference.

- --
Elliot Murphy | https://launchpad.net/~emurphy/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGeQ1QGi43imCMARIRAm9lAJsHIBFacBaMFdERGlo6/mXL0L4elQCfas2i
rbDjKAS3VbU+YTCw6L8Zn+A=
=/VIi
-----END PGP SIGNATURE-----

Revision history for this message
Lucius (luciusf) said :
#2

Elliot, Thanks a lot for your reply. I had stumbled over cdiff before when
I was researching on how to make color diffs work. All it does for me is
creating a different diff notation output to the command line. Here is an
example of lines that were added when typing bzr diff:

←[0m←[0;34m+ private void TimerCallbackProc(object param)
←[0m←[0;34m+ {
←[0m←[0;34m+ timeCounter -= timerTick;
←[0m←[0;34m+ if (timeCounter <= 0)
←[0m←[0;34m+ {
←[0m←[0;34m+ if (!replClient.IsBusy)
←[0m←[0;34m+ {
←[0m←[0;34m+ timeCounter = interval;
←[0m←[0;34m+ replClient.Run();
←[0m←[0;34m+ }
←[0m←[0;34m+ }
←[0m←[0;34m+ }

There is nothing colored about this output. I also installed some other
tools like gdiff. Even this does not color the output. I am using windows
and perhaps some of the commands work differently.
See screenshot.

Thanks again.
-Lucius

----- Original Message -----
From: "Elliot Murphy" <email address hidden>
To: <email address hidden>
Sent: Wednesday, June 20, 2007 4:18 AM
Subject: Re: [Question #8468]: colored diff

Your question #8468 on Bazaar changed:
https://answers.launchpad.net/bzr/+question/8468

    Status: Open => Answered

Elliot Murphy proposed the following answer:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 06/20/2007 02:04 AM, Lucius wrote:
> New question #8468 on Bazaar:
> https://answers.launchpad.net/bzr/+question/8468
>
> How do a I do colored diff? bzr diff just prints out the human-unreadable
> diff notation. I found one plugin that allows to pipe the bzr diff output
> to any third party diff tool.

Hi Lucius,

I personally use the 'cdiff' command which is added by the bzrtools
plugin. There is also a program (not associated with Bazaar) called
colordiff, which you can pipe any diff to and the diff will be colored.

So,

- - bzr cdiff
or
- - bzr diff | colordiff

depending on your preference.

- --
Elliot Murphy | https://launchpad.net/~emurphy/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGeQ1QGi43imCMARIRAm9lAJsHIBFacBaMFdERGlo6/mXL0L4elQCfas2i
rbDjKAS3VbU+YTCw6L8Zn+A=
=/VIi
-----END PGP SIGNATURE-----

_______________________________________________________________________
If this answers your question, please go to the following page to let us
know that it is solved:
https://answers.launchpad.net/bzr/+question/8468/+confirm?answer_id=0

If you still need help, you can reply to this email or go to the
following page to enter your feedback:
https://answers.launchpad.net/bzr/+question/8468

Revision history for this message
Elliot Murphy (statik) said :
#3

Hi Lucius,
Sorry, I didn't realize that you were using Windows. As you noticed, the escape codes that bzrtools uses to control the colors doesn't work on Windows. There are ways to set the color on windows, but it would take some additional programming in bzrtools. If there is a lot of demand for this I would consider working on a patch for it at some point. As a workaround, the colors probably work as expected if you use cygwin.

Revision history for this message
Lucius (luciusf) said :
#4

Thanks a lot for your reply. I don't know how many people use Bazaar on
Windows (though I am very curious to learn Bazaars usage data). It would be
very nice if the escape codes could be fixed. I would be glad doing it
myself, but being a C++/C# developer I do not know Python well enough. So
far I have been very happy with Bazaar on Windows, except for this one
problem.

To make color diff work on Windows, I have to install Colordiff which
requires Cygwin which requires Perl (in addition to Python required by
Bazaar). At some point I feel the chain of dependencies is becoming too
large, installation configuration and versioning too complicated due to too
many moving parts and the source control system brittle (at least on
Windows).

Alternatively I really like the command extension that allows to use any
diff tool, say kdiff3, if only the extension would not copy the whole tree
into a temp dir to show one single file diff and thereby causing tremendous
IO and slowing down my machine to a grinding halt. If this command extension
could become part of bzrtools, with its performance problems fixed I'd be
equally super happy.

Thanks a again for offering Bazaar to the public!

-Lucius

----- Original Message -----
From: "Elliot Murphy" <email address hidden>
To: <email address hidden>
Sent: Thursday, June 21, 2007 2:52 PM
Subject: Re: [Question #8468]: colored diff

Your question #8468 on Bazaar changed:
https://answers.launchpad.net/bzr/+question/8468

    Status: Open => Answered

Elliot Murphy proposed the following answer:
Hi Lucius,
Sorry, I didn't realize that you were using Windows. As you noticed, the
escape codes that bzrtools uses to control the colors doesn't work on
Windows. There are ways to set the color on windows, but it would take some
additional programming in bzrtools. If there is a lot of demand for this I
would consider working on a patch for it at some point. As a workaround, the
colors probably work as expected if you use cygwin.

--
If this answers your question, please go to the following page to let us
know that it is solved:
https://answers.launchpad.net/bzr/+question/8468/+confirm?answer_id=2

If you still need help, you can reply to this email or go to the
following page to enter your feedback:
https://answers.launchpad.net/bzr/+question/8468

You received this question notification because you are a direct
subscriber of the question.

Revision history for this message
Elliot Murphy (statik) said :
#5

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

> Thanks a lot for your reply. I don't know how many people use Bazaar on
> Windows (though I am very curious to learn Bazaars usage data). It would be
> very nice if the escape codes could be fixed. I would be glad doing it
> myself, but being a C++/C# developer I do not know Python well enough. So
> far I have been very happy with Bazaar on Windows, except for this one
> problem.

You may have the perfect background for fixing this. If you are
interested, take a look at this:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496901

The Windows cmd.exe program does not support escape codes for coloring
text, so to fix this the escape codes should not be printed on windows
(although the escape codes should still be printed on cygwin). Rather
than adding escape codes to the string that is printed, the console text
attributes need to be changed before printing each string (and reset
when done).

> Alternatively I really like the command extension that allows to use any
> diff tool, say kdiff3, if only the extension would not copy the whole tree
> into a temp dir to show one single file diff and thereby causing tremendous
> IO and slowing down my machine to a grinding halt. If this command extension
> could become part of bzrtools, with its performance problems fixed I'd be
> equally super happy.

I use the bzr difftools extension all the time, and I know there were
some recent fixes to not create a new working tree if the existing one
could be used. I can run 'bzr diff --using=meld foo.txt', and I don't
see a whole working tree created, I only see foo.txt created in a temp dir.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFGfslrGi43imCMARIRAhwSAKCcOF1OpNGi58X4QbVKu8h7BFTP/wCggo0E
mXyvkc+dQTSjguElGZuV78w=
=9Sxj
-----END PGP SIGNATURE-----

Revision history for this message
Lucius (luciusf) said :
#6

Yes, 'bzr diff --using=meld foo.txt' only copies foo.txt into temp dir.
However, the following two commands won't:

Show all differences between any two revisions:
bzr diff -r 1012..1014 --using windiff.exe
This creates two copies of the WHOLE working tree into temp dir, eventhough
the files that have changed is known and only those that have changes need
to be copied into temp.

Likewise, to see what has changed prior to commiting I run everytime
bzr diff --using windiff.exe
This creates also a copy of the WHOLE working tree in temp even though it is
known what files have changed.

The last two use cases are for me 90% of all diff use cases. I hope I am
missing something, since diffing is very important for me.
Thanks
-Lucius

On 6/24/07, Elliot Murphy <email address hidden> wrote:
>
> Your question #8468 on Bazaar changed:
> https://answers.launchpad.net/bzr/+question/8468
>
> Status: Open => Answered
>
> Elliot Murphy proposed the following answer:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> > Thanks a lot for your reply. I don't know how many people use Bazaar on
> > Windows (though I am very curious to learn Bazaars usage data). It
> would be
> > very nice if the escape codes could be fixed. I would be glad doing it
> > myself, but being a C++/C# developer I do not know Python well
> enough. So
> > far I have been very happy with Bazaar on Windows, except for this one
> > problem.
>
> You may have the perfect background for fixing this. If you are
> interested, take a look at this:
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496901
>
> The Windows cmd.exe program does not support escape codes for coloring
> text, so to fix this the escape codes should not be printed on windows
> (although the escape codes should still be printed on cygwin). Rather
> than adding escape codes to the string that is printed, the console text
> attributes need to be changed before printing each string (and reset
> when done).
>
> > Alternatively I really like the command extension that allows to use any
> > diff tool, say kdiff3, if only the extension would not copy the whole
> tree
> > into a temp dir to show one single file diff and thereby causing
> tremendous
> > IO and slowing down my machine to a grinding halt. If this command
> extension
> > could become part of bzrtools, with its performance problems fixed I'd
> be
> > equally super happy.
>
> I use the bzr difftools extension all the time, and I know there were
> some recent fixes to not create a new working tree if the existing one
> could be used. I can run 'bzr diff --using=meld foo.txt', and I don't
> see a whole working tree created, I only see foo.txt created in a temp
> dir.
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
>
> iD8DBQFGfslrGi43imCMARIRAhwSAKCcOF1OpNGi58X4QbVKu8h7BFTP/wCggo0E
> mXyvkc+dQTSjguElGZuV78w=
> =9Sxj
> -----END PGP SIGNATURE-----
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
> https://answers.launchpad.net/bzr/+question/8468/+confirm?answer_id=4
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https://answers.launchpad.net/bzr/+question/8468
>
> You received this question notification because you are a direct
> subscriber of the question.
>

Revision history for this message
Lukáš Lalinský (luks) said :
#7

Hi,

I'm not sure if this is exactly what you wanted, but I use 'bzr qdiff' for colored diff on Windows. See http://bazaar-vcs.org/QBzr.

Revision history for this message
Lucius (luciusf) said :
#8

Thanks a lot. I installed QBzr and this is exactly what I was looking for.
Great super simple installation experience and nice colored diff.
-Lucius

----- Original Message -----
From: "Lukáš Lalinský" <email address hidden>
To: <email address hidden>
Sent: Wednesday, June 27, 2007 6:00 AM
Subject: Re: [Question #8468]: colored diff

Your question #8468 on Bazaar changed:
https://answers.launchpad.net/bzr/+question/8468

    Status: Open => Answered

Lukáš Lalinský proposed the following answer:
Hi,

I'm not sure if this is exactly what you wanted, but I use 'bzr qdiff'
for colored diff on Windows. See http://bazaar-vcs.org/QBzr.

--
If this answers your question, please go to the following page to let us
know that it is solved:
https://answers.launchpad.net/bzr/+question/8468/+confirm?answer_id=6

If you still need help, you can reply to this email or go to the
following page to enter your feedback:
https://answers.launchpad.net/bzr/+question/8468

You received this question notification because you are a direct
subscriber of the question.

Revision history for this message
Launchpad Janitor (janitor) said :
#9

This question was expired because it remained in the 'Open' state without activity for the last 15 days.