Login | Register
My pages Projects Community openCollabNet

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

svnutils
Discussion topic

Back to topic list

CVS update: /svnutils/trunk/src/mergesvn

Author sunny256
Full name Øyvind A. Holm
Date 2007-03-05 08:44:13 PST
Message User: sunny256
Date: 2007-03-05 08:44:13-0800
Log:
 r183 | sunny256 | 2007-03-04 15:38:04 +0000 (Sun, 04 Mar 2007) | 3 lines
 
 * /trunk/src/mergesvn
   Added the "-d"/"--diff" option.

File Changes:

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

File [changed]: mergesvn
Url: http://svnutils.tigr​is.org/source/browse​/svnutils/trunk/src/​mergesvn?r1=1.9&​r2=1.10
Delta lines: +46 -5
--------------------
--- mergesvn 2007-03-05 08:43:25-0800 1.9
+++ mergesvn 2007-03-05 08:44:11-0800 1.10
@@ -1,7 +1,7 @@
 #!/usr/bin/perl -w
 
 #===================​====================​====================​============
-# $Id: mergesvn 182 2007-03-04 15:24:58Z sunny256 $
+# $Id: mergesvn 183 2007-03-04 15:38:04Z sunny256 $
 # Merges new changes into a file version controlled by Subversion.
 #
 # Character set: UTF-8
@@ -21,6 +21,7 @@
 our %Opt = (
     'alias' => "",
     'debug' => 0,
+ 'diff' => 0,
     'dry-run' => 0,
     'help' => 0,
     'to' => "HEAD",
@@ -30,7 +31,7 @@
 our $progname = $0;
 $progname =~ s#^.*/(.*?)$#$1#;
 
-my $rcs_id = '$Id: mergesvn 182 2007-03-04 15:24:58Z sunny256 $';
+my $rcs_id = '$Id: mergesvn 183 2007-03-04 15:38:04Z sunny256 $';
 my $id_date = $rcs_id;
 $id_date =~ s/^.*?\d+ (\d\d\d\d-.*?\d​\d:\d\d:\d\d\S​+).*/$1/;
 
@@ -38,6 +39,7 @@
 GetOptions(
     "alias|a=s" => \$Opt{'alias'},
     "debug" => \$Opt{'debug'},
+ "diff|d" => \$Opt{'diff'},
     "dry-run" => \$Opt{'dry-run'},
     "help|h" => \$Opt{'help'},
     "to|t=s" => \$Opt{'to'},
@@ -82,13 +84,24 @@
             my $master_file = length($Opt{'alias'})
                                 ? $Opt{'alias'}
                                 : $orig_master;
+ if (!$Opt{'diff'} && !$Opt{'dry-run'}) {
             mysyst($CMD_SVN, "update", $File);
+ }
             my $curr_rev = highest_revision($master_file, $Opt{'to'});
             if ($curr_rev !~ /^\d+$/) {
                 warn("$progname: $master_file: " .
                      "Unable to get newest revision\n");
                 next LOOP;
             }
+ if ($Opt{'diff'}) {
+ my $Repos = repos_url($File);
+ mysyst(
+ $CMD_SVN, "diff",
+ repos_url($master_file) . "\@$last_merge",
+ $Repos
+ );
+ next LOOP;
+ }
             if ($Opt{'dry-run'}) {
                 mysyst(
                     $CMD_SVN, "merge", "-r$last_merge:$curr_rev",
@@ -124,6 +137,16 @@
     # }}}
 } # highest_revision()
 
+sub repos_url {
+ # Return the repository address of an element {{{
+ my $File = shift;
+ my $safe_file = escape_filename($File);
+ my $Retval = `$CMD_SVN info --xml $safe_file`;
+ $Retval =~ s/^.*<url>(.*?​)<\/url>.*$/​$1/s;
+ return($Retval);
+ # }}}
+}
+
 sub mysyst {
     # Customised system() {{{
     my @Args = @_;
@@ -183,6 +206,9 @@
   -a x, --alias x
     Use x as alias for the master URL. The old value will still be
     written to the mergesvn property.
+ -d, --diff
+ Instead of merging, show a repository diff between the master URL
+ and the versioned element.
   --dry-run
     Try operation without making any changes. Can be used to see if the
     merge will result in conflicts.
@@ -225,7 +251,7 @@
 
 =head1 REVISION
 
-$Id: mergesvn 182 2007-03-04 15:24:58Z sunny256 $
+$Id: mergesvn 183 2007-03-04 15:38:04Z sunny256 $
 
 =head1 SYNOPSIS
 
@@ -261,6 +287,11 @@
 Use I<x> as alias for the master URL. The old value will still be
 written to the mergesvn property.
 
+=item B<-d>, B<--diff>
+
+Instead of merging, show a repository diff between the master URL and
+the versioned element.
+
 =item B<--dry-run>
 
 Try operation without making any changes.
@@ -284,6 +315,16 @@
 
 =back
 
+=head1 BUGS
+
+=over 4
+
+=item The svn(1) client does not support diffs between different
+repositories (yet), so the B<--diff> option will only work with elements
+that has the master in the same repository.
+
+=back
+
 =head1 AUTHOR
 
 Made by Øyvind A. Holm S<E<lt>sunn​y@sunbase.orgE<gt​>>.
@@ -318,4 +359,4 @@
 # }}}
 
 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :
-# End of file $Id: mergesvn 182 2007-03-04 15:24:58Z sunny256 $
+# End of file $Id: mergesvn 183 2007-03-04 15:38:04Z sunny256 $

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

Messages

Show all messages in topic

CVS update: /svnutils/trunk/src/mergesvn sunny256 Øyvind A. Holm 2007-03-05 08:44:13 PST
Messages per page: