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-04-07 06:10:03 PDT
Message User: sunny256
Date: 2007-04-07 06:10:03-0700
Log:
 r196 | sunny256 | 2007-04-02 23:11:44 +0000 (Mon, 02 Apr 2007) | 3 lines
 
 * /trunk/src/mergesvn
   Added the "-s"/"--set" option.

File Changes:

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

File [changed]: mergesvn
Url: http://svnutils.tigr​is.org/source/browse​/svnutils/trunk/src/​mergesvn?r1=1.17​&r2=1.18
Delta lines: +57 -4
--------------------
--- mergesvn 2007-04-07 06:09:18-0700 1.17
+++ mergesvn 2007-04-07 06:10:01-0700 1.18
@@ -1,7 +1,7 @@
 #!/usr/bin/perl -w
 
 #===================​====================​====================​============
-# $Id: mergesvn 195 2007-04-02 22:50:49Z sunny256 $
+# $Id: mergesvn 196 2007-04-02 23:11:44Z sunny256 $
 # Merges new changes into a file version controlled by Subversion.
 #
 # Character set: UTF-8
@@ -25,6 +25,7 @@
     'diff' => 0,
     'dry-run' => 0,
     'help' => 0,
+ 'set' => "",
     'to' => "HEAD",
     'version' => 0,
 );
@@ -32,7 +33,7 @@
 our $progname = $0;
 $progname =~ s#^.*/(.*?)$#$1#;
 
-my $rcs_id = '$Id: mergesvn 195 2007-04-02 22:50:49Z sunny256 $';
+my $rcs_id = '$Id: mergesvn 196 2007-04-02 23:11:44Z sunny256 $';
 my $id_date = $rcs_id;
 $id_date =~ s/^.*?\d+ (\d\d\d\d-.*?\d​\d:\d\d:\d\d\S​+).*/$1/;
 
@@ -44,6 +45,7 @@
     "diff|d" => \$Opt{'diff'},
     "dry-run" => \$Opt{'dry-run'},
     "help|h" => \$Opt{'help'},
+ "set|s=s" => \$Opt{'set'},
     "to|t=s" => \$Opt{'to'},
     "version" => \$Opt{'version'},
 ) || die("$progname: Option error. Use -h for help.\n");
@@ -69,6 +71,10 @@
 for (@Files) {
     # {{{
     my $File = $_;
+ if (length($Opt{'set'})) {
+ set_mergesvn_prop($File, $Opt{'set'});
+ next LOOP;
+ }
     my $prop_val = `$CMD_SVN propget $PROP_NAME $File`;
     if (!length($prop_val)) {
         warn("$progname: $File: \"$PROP_NAME\" property not found, " .
@@ -143,6 +149,40 @@
     return($Retval);
 }
 
+sub set_mergesvn_prop {
+ # Define the $PROP_NAME property for an element. Finds the highest
+ # revision which had a change.
+ # {{{
+ my ($File, $Str) = @_;
+ my ($Source, $source_rev) = ("", "");
+
+ if ($Str =~ /^(\S+)\@(\d*)$/) {
+ $Source = $1;
+ $source_rev = $2;
+ } elsif ($Str =~ /^(\S+)$/) {
+ $Source = $1;
+ $source_rev = "HEAD";
+ } else {
+ warn("$progname: $Str: Invalid source URL\n");
+ return(undef);
+ }
+ if ($source_rev =~ /[^\d]/ && $source_rev !~ /^HEAD$/i) {
+ die("$progname: $source_rev: Invalid source revision\n");
+ }
+ D("set_mergesvn_prop(): Source = '$Source', source_rev = '$source_rev'");
+ my $work_source = length($Opt{'alias'}) ? $Opt{'alias'} : $Source;
+ my $highest_rev = highest_revision($work_source, $source_rev);
+ D("set_mergesvn_prop(): highest_rev = '$highest_rev'");
+ if (!length($highest_rev)) {
+ die("$progname: $work_source: Unable to locate source revision\n");
+ }
+ if ($highest_rev ne $source_rev) {
+ warn("$progname: $File: Using revision $highest_rev instead of $source_rev\n");
+ }
+ mysyst($CMD_SVN, "propset", $PROP_NAME, "$highest_rev $Source", $File);
+ # }}}
+}
+
 sub find_conflict {
     # Scan a specific revision range for the first merge conflict and
     # return the revision number
@@ -342,6 +382,11 @@
     merge will result in conflicts.
   -h, --help
     Show this help.
+ -s x[\@y], --set x[\@y]
+ Set merge source for all filenames on the command line. If \@y is
+ specified, revision y will be used as the merge source, otherwise
+ HEAD is used. The revision number actually used is the newest
+ revision the source changed.
   -t x, --to x
     Merge to revision x instead of HEAD.
   --version
@@ -379,7 +424,7 @@
 
 =head1 REVISION
 
-$Id: mergesvn 195 2007-04-02 22:50:49Z sunny256 $
+$Id: mergesvn 196 2007-04-02 23:11:44Z sunny256 $
 
 =head1 SYNOPSIS
 
@@ -437,6 +482,14 @@
 
 Print a brief help summary.
 
+=item B<-s>, B<--set> I<x>[@I<y>]
+
+Set merge source for all filenames on the command line.
+If I<@y> is specified, revision y will be used as the merge source,
+otherwise HEAD is used.
+The revision number actually used is the newest revision the source
+changed.
+
 =item B<-t>, B<--to> I<x>
 
 Merge to revision I<x> instead of HEAD.
@@ -495,4 +548,4 @@
 # }}}
 
 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :
-# End of file $Id: mergesvn 195 2007-04-02 22:50:49Z sunny256 $
+# End of file $Id: mergesvn 196 2007-04-02 23:11:44Z 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-04-07 06:10:03 PDT
Messages per page: