Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: /svnutils/trunk/src/

svnutils
Discussion topic

Back to topic list

CVS update: /svnutils/trunk/src/

Author sunny256
Full name Øyvind A. Holm
Date 2005-04-28 22:15:46 PDT
Message User: sunny256
Date: 2005/04/28 22:15:46

Modified:
   svnutils/trunk/src/svndiff

Log:
 r129 | sunny256 | 2005-04-29 05:10:20 +0000 (Fri, 29 Apr 2005) | 6 lines
 
 Added the "reverse diff" functionality to programs specified in the
 ~/.svndiffrc file.
 
 * /trunk/src/svndiff
   Updated the XML parser and the POD.

File Changes:

Directory: /svnutils/trunk/src/
===============================

File [changed]: svndiff
Url: http://svnutils.tigr​is.org/source/browse​/svnutils/trunk/src/​svndiff?r1=1.24&​r2=1.25
Delta lines: +86 -5
--------------------
--- svndiff 28 Apr 2005 09:42:45 -0000 1.24
+++ svndiff 29 Apr 2005 05:15:43 -0000 1.25
@@ -1,7 +1,7 @@
 #!/usr/bin/perl -w
 
 #===================​====================​====================​============
-# $Id: svndiff 128 2005-04-28 09:35:00Z sunny256 $
+# $Id: svndiff 129 2005-04-29 05:10:20Z sunny256 $
 # Uses a specified diff program for viewing differences in a Subversion
 # versioned directory tree.
 #
@@ -34,6 +34,8 @@
 our $progname = $0;
 $progname =~ s#^(.*)/(.+?)$#$2#;
 
+my %rev_diff = ();
+
 my $rc_file = defined($ENV{SVNDIFFRC}) ? $ENV{SVNDIFFRC} : "";
 
 unless (length($rc_file)) {
@@ -177,7 +179,13 @@
                         return
                    );
 
- if ($Cmd eq "vimdiff") {
+ my $use_reverse = 0;
+
+ if (defined($rev_diff{$Cmd})) {
+ ($rev_diff{$Cmd} eq "1") && ($use_reverse = 1);
+ }
+
+ if ($use_reverse) {
         mysyst("$Cmd $File1 $File2");
     } else {
         mysyst("$Cmd $File2 $File1");
@@ -274,6 +282,55 @@
                 D("read_rcfile(): \$CMD_SVN = \"$CMD_SVN\"");
                 "";
             }sex;
+
+ $el_svndiffrc =~
+ s{
+ <reversediffs\b(​.*?)>(.*?)</re​versediffs>
+ }
+ {
+ my $el_reversediffs = $2;
+ D("Inside <reversediffs>​</reversediffs​>");
+
+ $el_reversediffs =~
+ s{
+ <program\b(.*?)​>(.*?)</program​>
+ }
+ {
+ my $el_program = $2;
+ D("Inside <program></​program>");
+
+ my ($Name, $Reverse) =
+ ( "", "");
+
+ $el_program =~
+ s{
+ <name\b(.*?)>​(.*?)</name>
+ }
+ {
+ $Name = xml_to_txt($2);
+ D("Name = \"$Name\"");
+ "";
+ }sex;
+
+ $el_program =~
+ s{
+ <reverse\b(.*?)​>(.*?)</reverse​>
+ }
+ {
+ $Reverse = xml_to_txt($2);
+ D("Reverse = \"$Reverse\"");
+ "";
+ }sex;
+
+ if (length($Name)) {
+ $rev_diff{$Name} = ($Reverse eq "1" ? 1 : 0);
+ D("\$rev_diff{$Name} = \"$rev_diff{$Name}\"");
+ } else {
+ warn("$progname: $File: Found empty <name></name> element\n");
+ }
+ "";
+ }gsex;
+ }sex;
             print_leftover($el_svndiffrc, "svndiffrc");
         }sex;
         print_leftover($el_top, "top");
@@ -355,7 +412,7 @@
 
 =head1 REVISION
 
-$Id: svndiff 128 2005-04-28 09:35:00Z sunny256 $
+$Id: svndiff 129 2005-04-29 05:10:20Z sunny256 $
 
 =head1 SYNOPSIS
 
@@ -415,9 +472,16 @@
   <svndiffrc>
     <diffprog>vimd​iff</diffprog>​
     <svnclient>svn​</svnclient>
+ <reversediffs>
+ <program>
+ <name>vimdiff​</name>
+ <reverse>1<​/reverse>
+ </program>
+ <!-- Several "program" element groups can be specified -->
+ </reversediffs>
   </svndiffrc>
 
-(Whitespace is optional and more options will come.)
+(Whitespace and linebreaks are optional.)
 
 The string inside the C<diffprog> elements can be set to whatever your
 diff program is called as, the default string is "vimdiff".
@@ -426,6 +490,23 @@
 C<svnclient> elements.
 The default value here is of course "svn".
 
+When using visual diff viewers (for example B<vimdiff>), the program
+expects the file names to be switched on the command line so your
+modified file appears in the correct window.
+By creating a C<E<lt>prog​ramE<gt>E<l​t>/programE<gt​>> section, programs
+can be instructed to take arguments the opposite way.
+If you for example use the B<meld> program and you want your modified
+file to be in the left window, add this to the file (I<inside> the
+C<E<lt>rev​ersediffsE<gt>​E<lt>/reversed​iffsE<gt>> elements):
+
+ <program>
+ <name>meld</name>
+ <reverse>1<​/reverse>
+ </program>
+
+The value in the C<reverse> element have to be B<1>, all other values
+will count as B<0>.
+
 =back
 
 =head1 ENVIRONMENT VARIABLES
@@ -473,4 +554,4 @@
 # }}}
 
 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :
-# End of file $Id: svndiff 128 2005-04-28 09:35:00Z sunny256 $
+# End of file $Id: svndiff 129 2005-04-29 05:10:20Z sunny256 $

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

CVS update: /svnutils/trunk/src/ sunny256 Øyvind A. Holm 2005-04-28 22:15:46 PDT
Messages per page: