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-05-11 21:04:10 PDT
Message User: sunny256
Date: 2005/05/11 21:04:10

Modified:
   svnutils/trunk/src/svndiff

Log:
 r142 | sunny256 | 2005-05-12 03:53:51 +0000 (Thu, 12 May 2005) | 8 lines
 
 Make svndiff work against URLs and not only local files. If an URL is
 used, the --revision option has to be specified.
 
 * /trunk/src/svndiff
   Works against URLs too.
   (is_url): New function.
   (usage, POD): Added URL info.

File Changes:

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

File [changed]: svndiff
Url: http://svnutils.tigr​is.org/source/browse​/svnutils/trunk/src/​svndiff?r1=1.31&​r2=1.32
Delta lines: +56 -20
---------------------
--- svndiff 12 May 2005 04:03:45 -0000 1.31
+++ svndiff 12 May 2005 04:04:08 -0000 1.32
@@ -1,7 +1,7 @@
 #!/usr/bin/perl -w
 
 #===================​====================​====================​============
-# $Id: svndiff 141 2005-05-12 03:44:01Z sunny256 $
+# $Id: svndiff 142 2005-05-12 03:53:51Z sunny256 $
 # Uses a specified diff program for viewing differences in a Subversion
 # versioned directory tree.
 #
@@ -81,9 +81,10 @@
     @mod_array = @ARGV;
     for my $Curr (@mod_array) {
         D("ARG = \"$Curr\"\n");
- if (-f $Curr && !-l $Curr) {
- D("$Curr is a file.");
+ if ((-f $Curr && !-l $Curr) || is_url($Curr)) {
+ D("$Curr is a file or URL.");
             my $has_conflict;
+ if (!is_url($Curr)) {
             D("Before PipeFP 1: CMD_SVN = \"$CMD_SVN\"");
             if (open(PipeFP, "$CMD_SVN stat $Curr -q |")) {
                 $has_conflict = (<PipeFP> =~ /$ST_CONFLICT/) ? 1 : 0;
@@ -91,6 +92,13 @@
                 warn("$progname: Error opening " .
                      "\"$CMD_SVN $Curr stat -q\" pipe: $!");
             }
+ } else {
+ if (!length($opt_revision)) {
+ die("$progname: Need to specify the --revision option " .
+ "when diffing an URL\n");
+ }
+ $has_conflict = 0;
+ }
             diff_file($Curr, $has_conflict, $opt_revision);
         } else {
             D("$Curr is NOT a file.");
@@ -162,6 +170,14 @@
             die("$progname: Revision format error in --revision argument, " .
                 "use -h for help\n");
         }
+ if (is_url($File1)) {
+ $tmp1 =~ s#^(\S+/)(\S+?)$#$2#;
+ length($Rev2) || ($Rev2 = "HEAD");
+ $tmp2 = "$File1.r$Rev2.tmp";
+ $tmp2 =~ s#^(\S+/)(\S+?)$#$2#;
+ } else {
+ $tmp2 = "$File1.r$Rev2.tmp";
+ }
         D("Rev1 = \"$Rev1\", Rev2 = \"$Rev2\"\n");
         (-e $tmp1)
             && (die("$progname: $tmp1: Temporary file already exists\n"));
@@ -190,6 +206,7 @@
     D("File1 = \"$File1\"\n");
     D("File2 = \"$File2\"\n");
 
+ if (!is_url($File1)) {
     (-e $File1) || (warn("$File1: File not found\n"), return);
     (-e $File2) || (warn("$File2: File not found" .
                          length($opt_revision) ? ""
@@ -198,6 +215,7 @@
                         ),
                         return
                    );
+ }
 
     my $use_reverse = 0;
 
@@ -253,6 +271,16 @@
     # }}}
 } # deb_wait()
 
+sub is_url {
+ # {{{
+ my $Url = shift;
+
+ my $Retval = ($Url =~ m#^\S+://\S+/#) ? 1 : 0;
+ D("is_url(\"$Url\") returns \"$Retval\".");
+ return($Retval);
+ # }}}
+} # is_url()
+
 sub mysyst {
     # {{{
     my @Args = @_;
@@ -405,6 +433,9 @@
 
 Usage: $progname [options] [file [...]]
 
+"file" can also be an URL, but then the --revision option has to be
+specified.
+
 Options:
 
 -C, --conflict Only run diff on conflicted files.
@@ -416,7 +447,9 @@
                     111:222
                       Compare r111 and r222.
                     123
- Compare your working file against r123.
+ Compare your working file against r123. If the
+ file is an URL, the second revision is set to
+ HEAD.
                     {2001-05-17T18:12:16Z}:900
                       Compare between a specific point in time with
                       r900.
@@ -438,7 +471,7 @@
 
 =head1 REVISION
 
-$Id: svndiff 141 2005-05-12 03:44:01Z sunny256 $
+$Id: svndiff 142 2005-05-12 03:53:51Z sunny256 $
 
 =head1 SYNOPSIS
 
@@ -449,6 +482,8 @@
 Run the specified diff program on every modified file in current
 directory and all subdirectories or on the files specified on the
 command line.
+An URL to a file can also be specified, but then the --revision option
+has to be specified.
 
 The program needs the L<svn(1)> commandline client to run.
 
@@ -485,7 +520,8 @@
   111:222
     Compare r111 and r222.
   123
- Compare your working file against r123.
+ Compare your working file against r123. If the file is an URL, the
+ second revision is set to HEAD.
 
 =back
 
@@ -607,4 +643,4 @@
 # }}}
 
 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :
-# End of file $Id: svndiff 141 2005-05-12 03:44:01Z sunny256 $
+# End of file $Id: svndiff 142 2005-05-12 03:53:51Z 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-05-11 21:04:10 PDT
Messages per page: