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 00:33:52 PDT
Message User: sunny256
Date: 2005/05/11 00:33:52

Modified:
   svnutils/trunk/src/svndiff

Log:
 r137 | sunny256 | 2005-05-11 07:25:44 +0000 (Wed, 11 May 2005) | 8 lines
 
 Use Getopt::Long instead of Getopt::Std to enable long options like
 --help and --revision.
 
 * /trunk/src/svndiff
   - use Getopt::Long.
   - The $opt_. variables are extended to their long option equivalents.
   (usage, POD): Updated.

File Changes:

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

File [changed]: svndiff
Url: http://svnutils.tigr​is.org/source/browse​/svnutils/trunk/src/​svndiff?r1=1.27&​r2=1.28
Delta lines: +49 -39
---------------------
--- svndiff 11 May 2005 07:32:35 -0000 1.27
+++ svndiff 11 May 2005 07:33:49 -0000 1.28
@@ -1,7 +1,7 @@
 #!/usr/bin/perl -w
 
 #===================​====================​====================​============
-# $Id: svndiff 136 2005-05-11 07:18:20Z sunny256 $
+# $Id: svndiff 137 2005-05-11 07:25:44Z sunny256 $
 # Uses a specified diff program for viewing differences in a Subversion
 # versioned directory tree.
 #
@@ -15,9 +15,11 @@
 
 $| = 1;
 
-use Getopt::Std;
-our ($opt_C, $opt_c, $opt_e, $opt_h, $opt_p, $opt_r) =
- ( 0, "", "", 0, "", "");
+use Getopt::Long;
+our ($opt_conflict, $opt_diffcmd, $opt_svncmd, $opt_help) =
+ ( 0, "", "", 0);
+our ($opt_diffargs, $opt_revision) =
+ ( "", "");
 
 my $Debug = 0;
 
@@ -52,16 +54,24 @@
 
 length($rc_file) && (-e $rc_file) && read_rcfile($rc_file);
 
-getopts('Cc:e:hp:r:') || die("$progname: Option error. Use -h for help.\n");
-
-$opt_h && usage(0);
-
-length($opt_c) && ($Cmd = $opt_c);
-length($opt_p) && ($Cmd .= " $opt_p");
-length($opt_e) && ($CMD_SVN = $opt_e);
+Getopt::Long::Confi​gure("bundling");
+GetOptions(
+ "conflict|C" => \$opt_conflict,
+ "diffcmd|c=s" => \$opt_diffcmd,
+ "svncmd|e=s" => \$opt_svncmd,
+ "help|h" => \$opt_help,
+ "diffargs|p=s" => \$opt_diffargs,
+ "revision|r=s" => \$opt_revision
+) || die("$progname: Option error. Use -h for help.\n");
+
+$opt_help && usage(0);
+
+length($opt_diffcmd) && ($Cmd = $opt_diffcmd);
+length($opt_diffargs) && ($Cmd .= " $opt_diffargs");
+length($opt_svncmd) && ($CMD_SVN = $opt_svncmd);
 
 my $stat_chars = "$ST_CONFLICT$ST_MODIFIED";
-$opt_C && ($stat_chars = "$ST_CONFLICT");
+$opt_conflict && ($stat_chars = "$ST_CONFLICT");
 
 my @mod_array = ();
 
@@ -79,7 +89,7 @@
             } else {
                 warn("$progname: Error opening \"$CMD_SVN $Curr stat -q\" pipe");
             }
- diff_file($Curr, $has_conflict, $opt_r);
+ diff_file($Curr, $has_conflict, $opt_revision);
         } else {
             D("$Curr is NOT a file.");
             warn("$progname: \"$Curr\" is not a file or doesn't exist\n");
@@ -88,7 +98,7 @@
     # }}}
 } else {
     # {{{
- length($opt_r) && die("You need to specify one or more files when using the -r option\n");
+ length($opt_revision) && die("You need to specify one or more files when using the -r option\n");
     D("Before PipeFP 2: CMD_SVN = \"$CMD_SVN\"");
     if (open(PipeFP, "$CMD_SVN stat -q |")) {
         my %has_conflict = ();
@@ -132,14 +142,14 @@
     my $File2 = "";
     my @rm_files = ();
 
- if (length($opt_r)) {
+ if (length($opt_revision)) {
         my ($Rev1, $Rev2);
         my ($tmp1, $tmp2);
- if ($opt_r =~ /^(\d+)$/) {
+ if ($opt_revision =~ /^(\d+)$/) {
             $Rev1 = $1;
             $Rev2 = "";
             $tmp1 = "$File1.r$Rev1.tmp";
- } elsif ($opt_r =~ /^(\d+):(\d+)$/) {
+ } elsif ($opt_revision =~ /^(\d+):(\d+)$/) {
             $Rev1 = $1;
             $Rev2 = $2;
             $tmp1 = "$File1.r$Rev1.tmp";
@@ -171,7 +181,7 @@
 
     (-e $File1) || (warn("$File1: File not found\n"), return);
     (-e $File2) || (warn("$File2: File not found" .
- length($opt_r) ? ""
+ length($opt_revision) ? ""
                                         : ", is not under version " .
                                           "control" .
                          "\n"
@@ -196,7 +206,7 @@
         unlink($curr_rm) || warn("$progname: $curr_rm: Can't delete temporary file: $!");
     }
 
- if (!length($opt_r) && $has_conflict) {
+ if (!length($opt_revision) && $has_conflict) {
         print("$progname: Write y and press ENTER if the conflict " .
               "in $File1 is resolved: ");
         if (<STDIN> =~ /^y$/i) {
@@ -384,12 +394,12 @@
 
 Options:
 
--C Only run diff on conflicted files.
--c x Use x as the diff command. Default: "$Cmd".
--e x Use x as the svn executable. Default: "$CMD_SVN".
--h Show this help.
--p x Use x as parameters to the diff program.
--r x Run a $Cmd command against previous revisions:
+-C, --conflict Only run diff on conflicted files.
+-c, --diffcmd x Use x as the diff command. Default: "$Cmd".
+-e, --svncmd x Use x as the svn executable. Default: "$CMD_SVN".
+-h, --help Show this help.
+-p, --diffargs x Use x as parameters to the diff program.
+-r, --revision x Run a $Cmd command against previous revisions:
         111:222
           Compare r111 and r222.
         123
@@ -412,7 +422,7 @@
 
 =head1 REVISION
 
-$Id: svndiff 136 2005-05-11 07:18:20Z sunny256 $
+$Id: svndiff 137 2005-05-11 07:25:44Z sunny256 $
 
 =head1 SYNOPSIS
 
@@ -426,31 +436,31 @@
 
 =over 4
 
-=item B<-C>
+=item B<-C>, B<--conflict>
 
 Only run diff on conflicted files.
 
-=item B<-c> x
+=item B<-c>, B<--diffcmd> x
 
 Use x as the diff command.
 Default: "svndiff".
 
-=item B<-e> x
+=item B<-e>, B<--svncmd> x
 
 Use x as the svn executable.
 Example:
 
   svndiff -e /usr/local/bin/svn-1.0
 
-=item B<-p> x
+=item B<-p>, B<--diffargs> x
 
 Use x as parameters to the diff program.
 
-=item B<-h>
+=item B<-h>, B<--help>
 
 Print a brief help summary.
 
-=item B<-r> x
+=item B<-r>, B<--revision> x
 
 Run the external diff command against previous revisions:
 
@@ -557,4 +567,4 @@
 # }}}
 
 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :
-# End of file $Id: svndiff 136 2005-05-11 07:18:20Z sunny256 $
+# End of file $Id: svndiff 137 2005-05-11 07:25:44Z 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 00:33:52 PDT
Messages per page: