commit colordiff for openSUSE:Factory

Hello community, here is the log from the commit of package colordiff for openSUSE:Factory checked in at Thu Mar 26 02:04:53 CET 2009. -------- --- colordiff/colordiff.changes 2007-06-24 21:29:50.000000000 +0200 +++ colordiff/colordiff.changes 2009-03-23 08:34:27.000000000 +0100 @@ -1,0 +2,19 @@ +Wed Mar 18 14:02:42 CET 2009 - mseben@suse.cz + +- updated to 1.0.8a version + +- Changes between version 1.0.6a and 1.0.7a + - Support introduced for 'wdiff' colourising (thanks to Tom Regner) + - Correctly handles undefined HOME (patches from various people). + - Support for p4 diffs added by Alexis Layton, plus bug fix for + blank first lines + +- Changes between version 1.0.7a and 1.0.8a + - Support for numeric colours added, for 256-colour terminals + (thanks to GautamIyer). + - Diff-types can now be specified explicitly, for use when + diff-type detection doesn't work or isn't possible. + - Return diff's exit code, patch from Tim Connors. Allow + extraneous diff text to be coloured separately. + +------------------------------------------------------------------- calling whatdependson for head-i586 Old: ---- colordiff-1.0.6a.tar.bz2 New: ---- colordiff-1.0.8a.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ colordiff.spec ++++++ --- /var/tmp/diff_new_pack.H15404/_old 2009-03-26 02:01:21.000000000 +0100 +++ /var/tmp/diff_new_pack.H15404/_new 2009-03-26 02:01:21.000000000 +0100 @@ -1,19 +1,27 @@ # -# spec file for package colordiff (Version 1.0.6a) +# spec file for package colordiff (Version 1.0.8a) # -# Copyright (c) 2007 SUSE LINUX Products GmbH, Nuernberg, Germany. -# This file and all modifications and additions to the pristine -# package are under the same license as the package itself. +# Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany. # +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + # Please submit bugfixes or comments via http://bugs.opensuse.org/ # + Name: colordiff -URL: http://colordiff.sourceforge.net/ -Version: 1.0.6a +Url: http://colordiff.sourceforge.net/ +Version: 1.0.8a Release: 1 -License: GPL +License: GPL v2 or later BuildRoot: %{_tmppath}/%{name}-%{version}-build Group: Productivity/Text/Utilities Summary: Colour-highlighted 'diff' output @@ -59,5 +67,19 @@ /etc/colordiffrc %changelog -* Sun Jun 24 2007 - bwalle@suse.de +* Wed Mar 18 2009 mseben@suse.cz +- updated to 1.0.8a version +- Changes between version 1.0.6a and 1.0.7a + - Support introduced for 'wdiff' colourising (thanks to Tom Regner) + - Correctly handles undefined HOME (patches from various people). + - Support for p4 diffs added by Alexis Layton, plus bug fix for + blank first lines +- Changes between version 1.0.7a and 1.0.8a + - Support for numeric colours added, for 256-colour terminals + (thanks to GautamIyer). + - Diff-types can now be specified explicitly, for use when + diff-type detection doesn't work or isn't possible. + - Return diff's exit code, patch from Tim Connors. Allow + extraneous diff text to be coloured separately. +* Sun Jun 24 2007 bwalle@suse.de - initial SUSE package ++++++ colordiff-1.0.6a.tar.bz2 -> colordiff-1.0.8a.tar.bz2 ++++++ diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/colordiff-1.0.6a/BUGS new/colordiff-1.0.8a/BUGS --- old/colordiff-1.0.6a/BUGS 2006-07-11 22:32:11.000000000 +0200 +++ new/colordiff-1.0.8a/BUGS 2007-11-05 21:51:10.000000000 +0100 @@ -8,3 +8,6 @@ workaround is to choose either colordiffrc or colordiffrc-lightbg, as appropriate for the colour scheme in use. +Colourising of 'wdiff' output requires that the '-n' option is given, i.e. +'wdiff -n', which avoids spanning the end of line while showing deleted or +inserted text. See 'man wdiff' diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/colordiff-1.0.6a/cdiff.1 new/colordiff-1.0.8a/cdiff.1 --- old/colordiff-1.0.6a/cdiff.1 1970-01-01 01:00:00.000000000 +0100 +++ new/colordiff-1.0.8a/cdiff.1 2009-01-25 12:18:59.000000000 +0100 @@ -0,0 +1,31 @@ +.\" Title: cdiff +.\" Author: +.\" Generator: DocBook XSL Stylesheets v1.73.2 <http://docbook.sf.net/> +.\" Date: 01/25/2009 +.\" Manual: +.\" Source: +.\" +.TH "CDIFF" "1" "01/25/2009" "" "" +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.SH "NAME" +cdiff \- a wrapper tool for colordiff +.SH "SYNOPSIS" +.HP 6 +\fBcdiff\fR {\fIURL\fR} +.SH "DESCRIPTION" +.PP +cdiff +is a wrapper for colordiff and will add colour to a diff given in a URL, e\&.g\&. +.sp +.RS 4 +.nf +cdiff http://some\&.url\&.com/foo/thing\&.patch +.fi +.RE +.SH "SEE ALSO" +.PP +cdiff +is part of the colordiff package, which should be consulted for further reference\&. diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/colordiff-1.0.6a/cdiff.xml new/colordiff-1.0.8a/cdiff.xml --- old/colordiff-1.0.6a/cdiff.xml 2006-04-16 21:39:32.000000000 +0200 +++ new/colordiff-1.0.8a/cdiff.xml 2009-01-25 12:18:50.000000000 +0100 @@ -22,121 +22,28 @@ <refsynopsisdiv id='synopsis'> <cmdsynopsis> <command>cdiff</command> - <arg><replaceable>&diff; options</replaceable></arg> - <arg choice='req'><replaceable>file1</replaceable></arg> - <arg choice='req'><replaceable>file2</replaceable></arg> + <arg choice='req'><replaceable>URL</replaceable></arg> </cmdsynopsis> </refsynopsisdiv> <refsect1 id='description'><title>Description</title> -<para>&colordiff; is a wrapper for &diff; and produces the same output as -&diff; but with coloured syntax highlighting at the command line to improve -readability. The output is similar to how a &diff;-generated patch might appear -in <application>Vim</application> or <application>Emacs</application> with the -appropriate syntax highlighting options enabled. The colour schemes can be -read from a central configuration file or from a local user -<filename>~/.colordiffrc</filename> file.</para> - -<para>&colordiff; makes use of ANSI colours and as such will only work when -ANSI colours can be used - typical examples are xterms and Eterms, as well as -console sessions.</para> - -<para>&colordiff; has been tested on various flavours of Linux and under -OpenBSD, but should be broadly portable to other systems.</para> - -</refsect1> - -<refsect1 id="usage"><title>Usage</title> - -<para>Use &colordiff; wherever you would normally use &diff;, or pipe output -to &colordiff;:</para> - -<para>For example: - -<screen> -$ colordiff file1 file2 -$ diff -u file1 file2 | colordiff -</screen> - -</para> - -<para>You can pipe the output to 'less', using the '-R' option (some systems or -terminal types may get better results using '-r' instead), which keeps -the colour escape sequences, otherwise displayed incorrectly or discarded by -'less': - -<screen> -$ diff -u file1 file2 | colordiff | less -R -</screen> - -</para> - -<para>You may find it useful to make &diff; automatically call -<command>colordiff</command>. Add the following line to -<filename>~/.bashrc</filename> (or equivalent): +<para>&cdiff; is a wrapper for colordiff and will add colour to a diff given +in a URL, e.g.</para> <screen> -alias diff=colordiff +cdiff http://some.url.com/foo/thing.patch </screen> -</para> - -<para>Any options passed to &colordiff; are passed through to &diff;.</para> - -<para>Alternatively, a construct such as 'cvs diff SOMETHING | colordiff' can be -included in <filename>~/.bashrc</filename> as follows: - -<screen> -function cvsdiff () { cvs diff $@ | colordiff; } -</screen> - -</para> - -<para>Or, combining the idea above using 'less': - -<screen> -function cvsdiff () { cvs diff $@ | colordiff |less -R; } -</screen> - -</para> - -<para>Note that the function name, cvsdiff, can be customized.</para> - </refsect1> -<refsect1 id='files'><title>Files</title> +<refsect1 id='seealso'><title>See Also</title> -<variablelist><varlistentry> - <term><filename>/etc/colordiffrc</filename></term> - <listitem><para>Central configuration file. User-specific settings can be - enabled by copying this file to <filename>~/.colordiffrc</filename> and - making the appropriate changes.</para></listitem> -</varlistentry></variablelist> - -</refsect1> - -<refsect1 id='bugs'><title>Bugs</title> - -<para>Bug reports and suggestions/patches to <email>davee@sungate.co.uk</email> -please.</para> - -<para>&colordiff; does not work for side-by-side diffs (<command>diff --y</command>). Note that <emphasis>does not work</emphasis> simply means that -the resulting output will not be colour-highlighted -- correct output will -still be produced.</para> - -</refsect1> - -<refsect1 id='author'><title>Author</title> - -<para>&colordiff; is written and maintained by Dave Ewart -<email>davee@sungate.co.uk</email>. This manual page and the -source XML was written by Graham Wilson <email>bob@decoy.wox.org</email> for -Debian and is maintained by the author. Graham Wilson also maintains the Debian -package for &colordiff;.</para> +<para>&cdiff; is part of the colordiff package, which should be consulted for +further reference.</para> </refsect1> </refentry> + <!-- vim:set ts=2 sw=2 et: --> diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/colordiff-1.0.6a/CHANGES new/colordiff-1.0.8a/CHANGES --- old/colordiff-1.0.6a/CHANGES 2006-09-13 21:43:58.000000000 +0200 +++ new/colordiff-1.0.8a/CHANGES 2009-01-25 12:09:01.000000000 +0100 @@ -78,5 +78,21 @@ Some changes have been made to the default colours used, to help visibility on as many different coloured terminals by default. +Changes between version 1.0.6 and 1.0.7 + +Support introduced for 'wdiff' colourising (thanks to Tom Regner); also +correctly handles undefined HOME (patches from various people). + +Support for p4 diffs added by Alexis Layton, plus bug fix for blank +first lines. + +Changes between version 1.0.7 and 1.0.8 + +Support for numeric colours added, for 256-colour terminals (thanks to Gautam +Iyer). Diff-types can now be specified explicitly, for use when diff-type +detection doesn't work or isn't possible. Return diff's exit code, patch from +Tim Connors. Allow extraneous diff text to be coloured separately. + + # vim: tw=72 diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/colordiff-1.0.6a/colordiff.1 new/colordiff-1.0.8a/colordiff.1 --- old/colordiff-1.0.6a/colordiff.1 2006-09-13 21:45:19.000000000 +0200 +++ new/colordiff-1.0.8a/colordiff.1 2009-01-25 12:18:56.000000000 +0100 @@ -1,113 +1,145 @@ -.\"Generated by db2man.xsl. Don't modify this, modify the source. -.de Sh \" Subsection -.br -.if t .Sp -.ne 5 -.PP -\fB\\$1\fR -.PP -.. -.de Sp \" Vertical space (when we can't use .PP) -.if t .sp .5v -.if n .sp -.. -.de Ip \" List item -.br -.ie \\n(.$>=3 .ne \\$3 -.el .ne 3 -.IP "\\$1" \\$2 -.. -.TH "COLORDIFF" 1 "" "" "" -.SH NAME +.\" Title: colordiff +.\" Author: +.\" Generator: DocBook XSL Stylesheets v1.73.2 <http://docbook.sf.net/> +.\" Date: 01/25/2009 +.\" Manual: +.\" Source: +.\" +.TH "COLORDIFF" "1" "01/25/2009" "" "" +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.SH "NAME" colordiff \- a tool to colorize diff output .SH "SYNOPSIS" -.ad l -.hy 0 .HP 10 -\fBcolordiff\fR [\fI\fBdiff\fR\ options\fR] {\fIfile1\fR} {\fIfile2\fR} -.ad -.hy - +\fBcolordiff\fR [\fI\fBdiff\fR\fR\fI\ options\fR] [\fIcolordiff\fR\fI\ options\fR] {\fIfile1\fR} {\fIfile2\fR} .SH "DESCRIPTION" - .PP -colordiff is a wrapper for \fBdiff\fR and produces the same output as \fBdiff\fR but with coloured syntax highlighting at the command line to improve readability\&. The output is similar to how a \fBdiff\fR\-generated patch might appear in Vim or Emacs with the appropriate syntax highlighting options enabled\&. The colour schemes can be read from a central configuration file or from a local user \fI~/\&.colordiffrc\fR file\&. - +colordiff +is a wrapper for +\fBdiff\fR +and produces the same output as +\fBdiff\fR +but with coloured syntax highlighting at the command line to improve readability\&. The output is similar to how a +\fBdiff\fR\-generated patch might appear in +Vim +or +Emacs +with the appropriate syntax highlighting options enabled\&. The colour schemes can be read from a central configuration file or from a local user +\fI~/\&.colordiffrc\fR +file\&. .PP -colordiff makes use of ANSI colours and as such will only work when ANSI colours can be used \- typical examples are xterms and Eterms, as well as console sessions\&. - +colordiff +makes use of ANSI colours and as such will only work when ANSI colours can be used \- typical examples are xterms and Eterms, as well as console sessions\&. .PP -colordiff has been tested on various flavours of Linux and under OpenBSD, but should be broadly portable to other systems\&. - +colordiff +has been tested on various flavours of Linux and under OpenBSD, but should be broadly portable to other systems\&. .SH "USAGE" - -.PP -Use colordiff wherever you would normally use \fBdiff\fR, or pipe output to colordiff: - .PP -For example: - -.IP - +Use +colordiff +wherever you would normally use +\fBdiff\fR, or pipe output to +colordiff: +.PP +For example: +.sp +.RS 4 +.nf $ colordiff file1 file2 $ diff \-u file1 file2 | colordiff - - +.fi +.RE .PP -You can pipe the output to 'less', using the '\-R' option (some systems or terminal types may get better results using '\-r' instead), which keeps the colour escape sequences, otherwise displayed incorrectly or discarded by 'less': - -.IP - +You can pipe the output to \'less\', using the \'\-R\' option (some systems or terminal types may get better results using \'\-r\' instead), which keeps the colour escape sequences, otherwise displayed incorrectly or discarded by \'less\': +.sp +.RS 4 +.nf $ diff \-u file1 file2 | colordiff | less \-R - - +.fi +.RE .PP -You may find it useful to make \fBdiff\fR automatically call \fBcolordiff\fR\&. Add the following line to \fI~/\&.bashrc\fR (or equivalent): - -.IP - +If you have +\fBwdiff\fR +installed, colordiff will correctly colourise the added and removed text, provided that the \'\-n\' option is given to +\fBwdiff\fR: +.sp +.RS 4 +.nf +$ wdiff \-n file1 file2 | colordiff +.fi +.RE +.PP +You may find it useful to make +\fBdiff\fR +automatically call +\fBcolordiff\fR\&. Add the following line to +\fI~/\&.bashrc\fR +(or equivalent): +.sp +.RS 4 +.nf alias diff=colordiff - - +.fi +.RE .PP -Any options passed to colordiff are passed through to \fBdiff\fR\&. - -.PP -Alternatively, a construct such as 'cvs diff SOMETHING | colordiff' can be included in \fI~/\&.bashrc\fR as follows: - -.IP - +Any options passed to +colordiff +are passed through to +\fBdiff\fR +except for the colordiff\-specific option \'difftype\', e\&.g\&. +.sp +.RS 4 +.nf +colordiff \-\-difftype=debdiff file1 file2 +.fi +.RE +.PP +Valid values for \'difftype\' are: diff, diffc, diffu, diffy, wdiff, debdiff; these correspond to plain diffs, context diffs, unified diffs, side\-by\-side diffs, wdiff output and debdiff output respectively\&. Use these overrides when colordiff is not able to determine the diff\-type automatically\&. +.PP +Alternatively, a construct such as \'cvs diff SOMETHING | colordiff\' can be included in +\fI~/\&.bashrc\fR +as follows: +.sp +.RS 4 +.nf function cvsdiff () { cvs diff $@ | colordiff; } - - +.fi +.RE .PP -Or, combining the idea above using 'less': - -.IP - +Or, combining the idea above using \'less\': +.sp +.RS 4 +.nf function cvsdiff () { cvs diff $@ | colordiff |less \-R; } - - +.fi +.RE .PP Note that the function name, cvsdiff, can be customized\&. - .SH "FILES" - -.TP +.PP \fI/etc/colordiffrc\fR -Central configuration file\&. User\-specific settings can be enabled by copying this file to \fI~/\&.colordiffrc\fR and making the appropriate changes\&. - -.TP +.RS 4 +Central configuration file\&. User\-specific settings can be enabled by copying this file to +\fI~/\&.colordiffrc\fR +and making the appropriate changes\&. +.RE +.PP \fIcolordiffrc\-lightbg\fR +.RS 4 Alternate configuration template for use with terminals having light backgrounds\&. Copy this to /etc/colordiffrc or ~/\&.colordiffrc and customize\&. - +.RE .SH "BUGS" - .PP -Bug reports and suggestions/patches to <davee@sungate\&.co\&.uk> please\&. - +Bug reports and suggestions/patches to +<davee@sungate\&.co\&.uk> +please\&. .SH "AUTHOR" - .PP -colordiff is written and maintained by Dave Ewart <davee@sungate\&.co\&.uk>\&. This manual page and the source XML was written by Graham Wilson <graham@mknod\&.org> for Debian and is maintained by the author\&. Dave Ewart maintains the Debian package, sponsored by Graham Wilson\&. - +colordiff +is written and maintained by Dave Ewart +<davee@sungate\&.co\&.uk>\&. This manual page and the source XML was written by Graham Wilson +<graham@mknod\&.org> +for Debian and is maintained by the author\&. Dave Ewart maintains the Debian package, sponsored by Graham Wilson\&. diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/colordiff-1.0.6a/colordiff.pl new/colordiff-1.0.8a/colordiff.pl --- old/colordiff-1.0.6a/colordiff.pl 2006-09-17 20:52:06.000000000 +0200 +++ new/colordiff-1.0.8a/colordiff.pl 2009-01-25 12:06:48.000000000 +0100 @@ -5,7 +5,7 @@ # ColorDiff - a wrapper/replacment for 'diff' producing # # colourful output # # # -# Copyright (C)2002-2006 Dave Ewart (davee@sungate.co.uk) # +# Copyright (C)2002-2009 Dave Ewart (davee@sungate.co.uk) # # # ######################################################################## # # @@ -26,11 +26,11 @@ use IPC::Open2; my $app_name = 'colordiff'; -my $version = '1.0.6'; +my $version = '1.0.8'; my $author = 'Dave Ewart'; my $author_email = 'davee@sungate.co.uk'; my $app_www = 'http://colordiff.sourceforge.net/'; -my $copyright = '(C)2002-2006'; +my $copyright = '(C)2002-2009'; my $show_banner = 1; my $color_patch = 0; @@ -64,14 +64,16 @@ # Locations for personal and system-wide colour configurations my $HOME = $ENV{HOME}; my $etcdir = '/etc'; - my ($setting, $value); -my @config_files = ("$etcdir/colordiffrc", "$HOME/.colordiffrc"); +my @config_files = ("$etcdir/colordiffrc"); +push (@config_files, "$ENV{HOME}/.colordiffrc") if (defined $ENV{HOME}); my $config_file; foreach $config_file (@config_files) { - if (open(COLORDIFFRC, "<$config_file")) { + if (open (COLORDIFFRC, "<$config_file")) { while (<COLORDIFFRC>) { + my $colourval; + chop; next if (/^#/ || /^$/); s/\s+//g; @@ -93,28 +95,43 @@ next; } $setting =~ tr/A-Z/a-z/; - $value =~ tr/A-Z/a-z/; + $value =~ tr/A-Z/a-z/; if (($value eq 'normal') || ($value eq 'none')) { $value = 'off'; } - if (!defined $colour{$value}) { + if ($value =~ m/[0-9]+/ && $value >= 0 && $value <= 255) { + # Numeric color + if( $value < 8 ) { + $colourval = "\033[0;3${value}m"; + } + elsif( $value < 15 ) { + $colourval = "\033[0;9${value}m"; + } + else { + $colourval = "\033[0;38;5;${value}m"; + } + } + elsif (defined($colour{$value})) { + $colourval = $colour{$value}; + } + else { print STDERR "Invalid colour specification for setting $setting ($value) in $config_file\n"; next; } if ($setting eq 'plain') { - $plain_text = $colour{$value}; + $plain_text = $colourval; } elsif ($setting eq 'oldtext') { - $file_old = $colour{$value}; + $file_old = $colourval; } elsif ($setting eq 'newtext') { - $file_new = $colour{$value}; + $file_new = $colourval; } elsif ($setting eq 'diffstuff') { - $diff_stuff = $colour{$value}; + $diff_stuff = $colourval; } elsif ($setting eq 'cvsstuff') { - $cvs_stuff = $colour{$value}; + $cvs_stuff = $colourval; } else { print STDERR "Unknown option in $config_file: $setting\n"; @@ -127,54 +144,51 @@ # If output is to a file, switch off colours, unless 'color_patch' is set # Relates to http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=378563 if ((-f STDOUT) && ($color_patch == 0)) { - $plain_text=''; - $file_old=''; - $file_new=''; - $diff_stuff=''; - $cvs_stuff=''; - $plain_text=''; - $colour{off}=''; + $plain_text = ''; + $file_old = ''; + $file_new = ''; + $diff_stuff = ''; + $cvs_stuff = ''; + $plain_text = ''; + $colour{off} = ''; } +my $specified_difftype; +GetOptions( + "difftype=s" => \$specified_difftype +); +# TODO - check that specified type is valid, issue warning if not # ---------------------------------------------------------------------------- -# FIXME -# -# Remove this (contributed) code for now - the long options break the addition -# of extra diff options supplied on the command line. On balance, modifying the -# diff options is probably more important than having colordiff customisations -# on the command line. -# -# Need to find a proper fix for this so that this can be reincluded - -### GetOptions( -### "no-banner" => sub { $show_banner = 0 }, -### "plain-text=s" => \&set_color, -### "file-old=s" => \&set_color, -### "file-new=s" => \&set_color, -### "cvs-stuff=s" => \&set_color, -### "diff-stuff=s" => \&set_color -### ); -# ---------------------------------------------------------------------------- if ($show_banner == 1) { print STDERR "$app_name $version ($app_www)\n"; print STDERR "$copyright $author, $author_email\n\n"; } +# FIXME - work out some magic here to make it rip off +# colordiff-specific long options, such as: +# +# --difftype={plain,context,unified,sideside,debdiff} +# +# then, optionally, throw away other options if in a pipe + my @inputstream; -if (defined $ARGV[0]) { +my $exitcode = 0; +if ((defined $ARGV[0]) && (-t STDIN)) { # More reliable way of pulling in arguments - open2(\*INPUTSTREAM, undef, "diff", @ARGV); + my $pid = open2(\*INPUTSTREAM, undef, "diff", @ARGV); @inputstream = <INPUTSTREAM>; close INPUTSTREAM; + waitpid $pid, 0; + $exitcode=$? >> 8; } else { @inputstream = <STDIN>; } -# Input stream has been read - need to examine it +# Input stream has been read - need to examine it # to determine type of diff we have. # # This may not be perfect - should identify most reasonably @@ -185,9 +199,13 @@ my $longest_record = 0; DIFF_TYPE: foreach $record (@inputstream) { + if (defined $specified_difftype) { + $diff_type = $specified_difftype; + last DIFF_TYPE; + } # Unified diffs are the only flavour having '+++' or '---' # at the start of a line - if ($record =~ /^(\+\+\+|---)/) { + if ($record =~ /^(\+\+\+|---|@@)/) { $diff_type = 'diffu'; last DIFF_TYPE; } @@ -210,6 +228,16 @@ $diff_type = 'diffy'; last DIFF_TYPE; } + # wdiff deleted/added patterns + # should almost always be pairwaise? + elsif ($record =~ /\[-.*?-\]/s) { + $diff_type = 'wdiff'; + last DIFF_TYPE; + } + elsif ($record =~ /\{\+.*?\+\}/s) { + $diff_type = 'wdiff'; + last DIFF_TYPE; + } } my $inside_file_old = 1; @@ -221,9 +249,9 @@ # second consists only of spaces, '<', '>' and '|' # This is not a 100% certain match, but should be good enough -my %separator_col = (); -my %candidate_col = (); -my $diffy_sep_col = 0; +my %separator_col = (); +my %candidate_col = (); +my $diffy_sep_col = 0; my $mostlikely_sum = 0; if ($diff_type eq 'diffy') { @@ -231,34 +259,37 @@ # Unfortunately requires parsing the input stream multiple times foreach (@inputstream) { # Convert tabs to spaces - while ((my $i = index($_, "\t")) > -1) { - substr( - $_, $i, 1, # range to replace - (' ' x (8 - ($i % 8))), # string to replace with - ); + while ((my $i = index ($_, "\t")) > -1) { + substr ( + $_, $i, 1, # range to replace + (' ' x (8 - ($i % 8))), # string to replace with + ); } $record = $_; - $longest_record = length($record) if (length($record) > $longest_record); + $longest_record = length ($record) if (length ($record) > $longest_record); } - for(my $i=0;$i <= $longest_record;$i++) { + for (my $i = 0 ; $i <= $longest_record ; $i++) { $separator_col{$i} = 1; $candidate_col{$i} = 0; } foreach (@inputstream) { # Convert tabs to spaces - while ((my $i = index($_, "\t")) > -1) { - substr( - $_, $i, 1, # range to replace - (' ' x (8 - ($i % 8))), # string to replace with - ); + while ((my $i = index ($_, "\t")) > -1) { + substr ( + $_, $i, 1, # range to replace + (' ' x (8 - ($i % 8))), # string to replace with + ); } - for(my $i=0;$i<(length($_)-2);$i++) { + for (my $i = 0 ; $i < (length ($_) - 2) ; $i++) { next if (!defined $separator_col{$i}); next if ($separator_col{$i} == 0); - my $subsub = substr($_,$i,2); - if ( ($subsub ne ' ') && ($subsub ne ' |') && ($subsub ne ' >') && - ($subsub ne ' <') ) { + my $subsub = substr ($_, $i, 2); + if ( ($subsub ne ' ') + && ($subsub ne ' |') + && ($subsub ne ' >') + && ($subsub ne ' <')) + { $separator_col{$i} = 0; } if (($subsub eq ' |') || ($subsub eq ' >') || ($subsub eq ' <')) { @@ -267,10 +298,10 @@ } } - for(my $i=0;$i<$longest_record-2;$i++) { + for (my $i = 0 ; $i < $longest_record - 2 ; $i++) { if ($separator_col{$i} == 1) { if ($candidate_col{$i} > $mostlikely_sum) { - $diffy_sep_col = $i; + $diffy_sep_col = $i; $mostlikely_sum = $i; } } @@ -286,12 +317,15 @@ elsif (/^>/) { print "$file_new"; } - elsif (/^[1-9]/) { + elsif (/^[0-9]/) { print "$diff_stuff"; } - elsif (/^(Index: |={5,}|RCS file: |retrieving |diff )/) { + elsif (/^(Index: |={4,}|RCS file: |retrieving |diff )/) { print "$cvs_stuff"; } + elsif (/^Only in/) { + print "$diff_stuff"; + } else { print "$plain_text"; } @@ -306,6 +340,9 @@ elsif (/^\*{4,}/) { print "$diff_stuff"; } + elsif (/^Only in/) { + print "$diff_stuff"; + } elsif (/^\*\*\* [0-9]+,[0-9]+/) { print "$diff_stuff"; $inside_file_old = 1; @@ -328,7 +365,7 @@ print "$file_new"; } } - elsif (/^(Index: |={5,}|RCS file: |retrieving |diff )/) { + elsif (/^(Index: |={4,}|RCS file: |retrieving |diff )/) { print "$cvs_stuff"; } else { @@ -345,7 +382,10 @@ elsif (/^\@/) { print "$diff_stuff"; } - elsif (/^(Index: |={5,}|RCS file: |retrieving |diff )/) { + elsif (/^Only in/) { + print "$diff_stuff"; + } + elsif (/^(Index: |={4,}|RCS file: |retrieving |diff )/) { print "$cvs_stuff"; } else { @@ -355,8 +395,8 @@ # Works with previously-identified column containing the diff-y # separator characters elsif ($diff_type eq 'diffy') { - if (length($_) > ($diffy_sep_col+2)) { - my $sepchars = substr($_, $diffy_sep_col, 2); + if (length ($_) > ($diffy_sep_col + 2)) { + my $sepchars = substr ($_, $diffy_sep_col, 2); if ($sepchars eq ' <') { print "$file_old"; } @@ -370,18 +410,23 @@ print "$plain_text"; } } + elsif (/^Only in/) { + print "$diff_stuff"; + } else { print "$plain_text"; } } + elsif ($diff_type eq 'wdiff') { + $_ =~ s/(\[-[^]]*?-\])/$file_old$1$colour{off}/g; + $_ =~ s/(\{\+[^]]*?\+\})/$file_new$1$colour{off}/g; + } + elsif ($diff_type eq 'debdiff') { + $_ =~ s/(\[-[^]]*?-\])/$file_old$1$colour{off}/g; + $_ =~ s/(\{\+[^]]*?\+\})/$file_new$1$colour{off}/g; + } s/$/$colour{off}/; print "$_"; } -# FIXME - See earlier commented-out code -### sub set_color { -### my ($type, $color) = @_; -### -### $type =~ s/-/_/; -### eval "\$$type = \$colour{$color}"; -### } +exit $exitcode; diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/colordiff-1.0.6a/colordiff.xml new/colordiff-1.0.8a/colordiff.xml --- old/colordiff-1.0.6a/colordiff.xml 2006-07-11 22:38:03.000000000 +0200 +++ new/colordiff-1.0.8a/colordiff.xml 2009-01-25 11:59:25.000000000 +0100 @@ -23,6 +23,7 @@ <cmdsynopsis> <command>colordiff</command> <arg><replaceable>&diff; options</replaceable></arg> + <arg><replaceable>&colordiff; options</replaceable></arg> <arg choice='req'><replaceable>file1</replaceable></arg> <arg choice='req'><replaceable>file2</replaceable></arg> </cmdsynopsis> @@ -72,6 +73,16 @@ </para> +<para>If you have <command>wdiff</command> installed, colordiff will correctly +colourise the added and removed text, provided that the '-n' option is given to +<command>wdiff</command>: + +<screen> +$ wdiff -n file1 file2 | colordiff +</screen> + +</para> + <para>You may find it useful to make &diff; automatically call <command>colordiff</command>. Add the following line to <filename>~/.bashrc</filename> (or equivalent): @@ -82,7 +93,17 @@ </para> -<para>Any options passed to &colordiff; are passed through to &diff;.</para> +<para>Any options passed to &colordiff; are passed through to &diff; except for +the colordiff-specific option 'difftype', e.g.</para> + +<screen> +colordiff --difftype=debdiff file1 file2 +</screen> + +<para>Valid values for 'difftype' are: diff, diffc, diffu, diffy, wdiff, debdiff; +these correspond to plain diffs, context diffs, unified diffs, side-by-side +diffs, wdiff output and debdiff output respectively. Use these overrides when +colordiff is not able to determine the diff-type automatically.</para> <para>Alternatively, a construct such as 'cvs diff SOMETHING | colordiff' can be included in <filename>~/.bashrc</filename> as follows: diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/colordiff-1.0.6a/Makefile new/colordiff-1.0.8a/Makefile --- old/colordiff-1.0.6a/Makefile 2007-04-25 21:18:54.000000000 +0200 +++ new/colordiff-1.0.8a/Makefile 2009-01-25 19:54:04.000000000 +0100 @@ -1,10 +1,10 @@ INSTALL_DIR=/usr/local/bin MAN_DIR=/usr/local/man/man1 ETC_DIR=/etc -VERSION=1.0.6a +VERSION=1.0.8a DIST_FILES=COPYING INSTALL Makefile README \ colordiff.pl colordiffrc colordiffrc-lightbg cdiff.sh BUGS TODO CHANGES colordiff.1 \ - colordiff.xml cdiff.xml + colordiff.xml cdiff.xml cdiff.1 TMPDIR=colordiff-${VERSION} TARBALL=${TMPDIR}.tar.gz @@ -29,6 +29,7 @@ install cdiff.sh ${INSTALL_DIR}/cdiff; \ fi install -D colordiff.1 ${MAN_DIR}/colordiff.1 + install -D cdiff.1 ${MAN_DIR}/cdiff.1 if [ -f ${ETC_DIR}/colordiffrc ]; then \ mv -f ${ETC_DIR}/colordiffrc ${ETC_DIR}/colordiffrc.old; \ fi @@ -37,6 +38,11 @@ chmod 644 ${ETC_DIR}/colordiffrc rm -f colordiff.pl.for.install +uninstall: etc + rm -f ${INSTALL_DIR}/colordiff + rm -f ${ETC_DIR}/colordiffrc + rm -f ${INSTALL_DIR}/cdiff + dist: mkdir ${TMPDIR} cp -p ${DIST_FILES} ${TMPDIR} diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/colordiff-1.0.6a/README new/colordiff-1.0.8a/README --- old/colordiff-1.0.6a/README 2006-09-13 21:45:21.000000000 +0200 +++ new/colordiff-1.0.8a/README 2009-01-25 19:53:24.000000000 +0100 @@ -39,6 +39,11 @@ $ diff -u file1 file2 | colordiff | less -R +If you have wdiff installed, colordiff will correctly colourise the added and +removed text, provided that the '-n' option is given to wdiff: + +$ wdiff -n file1 file2 | colordiff + You may find it useful to make diff automatically call colordiff. Add the following line to ~/.bashrc (or equivalent): @@ -57,6 +62,16 @@ Note that the function name, cvsdiff, can be customized. +Any options passed to colordiff are passed through to diff except for +the colordiff-specific option 'difftype', e.g. + +colordiff --difftype=debdiff file1 file2 + +Valid values for 'difftype' are: diff, diffc, diffu, diffy, wdiff, debdiff; +these correspond to plain diffs, context diffs, unified diffs, side-by-side +diffs, wdiff output and debdiff output respectively. Use these overrides when +colordiff is not able to determine the diff-type automatically. + Files /etc/colordiffrc @@ -78,5 +93,5 @@ colordiff is written and maintained by Dave Ewart <davee@sungate.co.uk>. This manual page and the source XML was written by Graham Wilson <graham@mknod.org> for Debian and is maintained by the author. Dave Ewart maintains the Debian -package, sponsored by Graham Wilson. +package. ++++++ colordiff-fix-permission.diff ++++++ --- /var/tmp/diff_new_pack.H15404/_old 2009-03-26 02:01:22.000000000 +0100 +++ /var/tmp/diff_new_pack.H15404/_new 2009-03-26 02:01:22.000000000 +0100 @@ -1,7 +1,7 @@ -Index: colordiff-1.0.6/Makefile +Index: colordiff-1.0.8/Makefile =================================================================== ---- colordiff-1.0.6.orig/Makefile -+++ colordiff-1.0.6/Makefile +--- colordiff-1.0.8.orig/Makefile ++++ colordiff-1.0.8/Makefile @@ -32,9 +32,7 @@ install: etc if [ -f ${ETC_DIR}/colordiffrc ]; then \ mv -f ${ETC_DIR}/colordiffrc ${ETC_DIR}/colordiffrc.old; \ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Remember to have fun... -- To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-commit+help@opensuse.org
participants (1)
-
root@Hilbert.suse.de