Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Problem on subversion using propset with perl on a svn:external

Reply
Thread Tools

Problem on subversion using propset with perl on a svn:external

 
 
Hartigan
Guest
Posts: n/a
 
      11-02-2009
Hi all,
i'm working to create some perl scripts to make changes on a svn(subversion)
respository. One of this script try to change a svn:external but i have
a problem to do this with the propset().

I have a testing repository with this path

http://localhost/svn/testing/develop_area/mail

under this directory there are two svn:externals:

[laforge:302]$svn propget svn:externals http://localhost/svn/testing/develop_area/mail/
stable http://localhost/svn/testing/main/ma...e-release-1.64
develop http://localhost/svn/testing/main/mail/trunk

With perl i want to change the stable external to a new branch and this
a expert of the script that try to make this change:

[...]
print "Get svn:external\n";
print "================\n";
my $hash =
$ctx->propget("svn:externals","http://localhost/svn/testing/develop_area/mail",$revision,"0");
my $newexternal="";
my $setprop="";
my ($key, $value) = each(%$hash);
print "Key:$key\n\nValue:\n$value\n";
my $count="1";
foreach (split(/\n/,$value)) {
my $external=$_;
print "-----------------\n";
print "External$count: $external\n";
$count++;
my @exter=split(/\s+/,$external);
print "+++++++++++++++++++++\n";
print "\tName: $exter[0]\n";
print "\tUrl: $exter[1]\n";
if ( $exter[0] eq "stable" ) {
$exter[1]="https://localhost/svn/testing/main/mail/branches/maintenance-release-1.65";
$setprop="1";
}
$newexternal=$newexternal."$exter[0] $exter[1]\n";
}


print "\n\n\n";
if ( $setprop eq "1" ) {
print "Set svn:external\n";
print "================\n";
print "Key:$key\n\n";
print "Value:\n";
print $newexternal;
$ctx->propset("svn:externals",$newexternal,"http://localhost/svn/testing/develop_area/mail","0");
} else {
print "Value:\n";
print $value;
}
[...]

Running the script i have an error during the operation:

[laforge:303]$./update-svn.pl
Connect operation
================
Set log message
================
Get svn:external
================
Key:http://localhost/svn/testing/develop_area/mail

Value:
stable
http://localhost/svn/testing/main/ma...e-release-1.64
develop http://localhost/svn/testing/main/mail/trunk

-----------------
External1: stable
http://localhost/svn/testing/main/ma...e-release-1.64
+++++++++++++++++++++
Name: stable
Url:
http://localhost/svn/testing/main/ma...e-release-1.64
-----------------
External2: develop http://localhost/svn/testing/main/mail/trunk
+++++++++++++++++++++
Name: develop
Url: http://localhost/svn/testing/main/mail/trunk



Set svn:external
================
Key:http://localhost/svn/testing/develop_area/mail

Value:
stable https://localhost/svn/testing/main/m...e-release-1.65
develop http://localhost/svn/testing/main/mail/trunk

i have this error:

Uncaught exception from user code:
Bogus revision information given: Setting property on non-local target
'http://localhost/svn/testing/develop_area/mail' needs a base revision at ./update-svn.pl line 84
at /usr/lib/perl5/vendor_perl/5.10.0/i386-linux-thread-multi/SVN/Core.pm line 632
SVN::Error::croak_on_error('_p_svn_error_t=SCALAR( 0x947ff44)') called at
/usr/lib/perl5/vendor_perl/5.10.0/i386-linux-thread-multi/SVN/Client.pm line 927
SVN::Client::__ANON__(undef, 'svn:externals', 'stable
https://localhost/svn/testing/main/mail/branches/maint...', 'http://localhost/svn/testing/develop_area/mail', 0) called
at ./update-svn.pl line 84

With the cli command i can change the svn:externals without problem.

I'm on linux, distribution Fedora 10
Subversion command-line client, version 1.6.5.
Summary of my perl5 (revision 5 version 10 subversion 0) configuration:

Rpm package version:
subversion-1.6.5-1.fc10.1.i386
subversion-perl-1.6.5-1.fc10.1.i386
mod_dav_svn-1.6.5-1.fc10.1.i386

Anyone have an idea about this problem ?
Any idea on how change a svn:externals via perl on a remote repository?

Thank you
 
Reply With Quote
 
 
 
 
Hartigan
Guest
Posts: n/a
 
      11-09-2009
If someone need something that change a svn:external on a remote svn repository can try to start with lines of code.
The problem is that the SVN::Client not support the change of the prop in a remote repository (the command line yes with
propedit...). So the idea is to get the url, checkout it, change on the working copy, commit, and remove the temporary
working copy...
If someone need to do something like this, this is a base, so you don't loose time like me to understand why not work...


use SVN::Client;
use File::Remove 'remove';

sub svnupdateexternals {
my ($svn_ext_ctx,$svn_ext_url,$svn_ext_link,$svn_ext_ target) = @_;
my $recursive = "0";
my $svn_ext_path = "/tmp/external-update-".$$;
my $svn_ext_name="svn:externals";
my $svn_ext_rev="HEAD";
my $svn_ext_force="0";
my $svn_ext_hash = $svn_ext_ctx->propget($svn_ext_name,$svn_ext_url,$svn_ext_rev,$ svn_ext_force);
my $svn_ext_newexternal="";
my $svn_ext_setprop="";
my $svn_ext_count="1";
my ($svn_ext_key, $svn_ext_value) = each(%$svn_ext_hash);
print "Key:$svn_ext_key\n\nValue:\n$svn_ext_value\n" ;
foreach (split(/\n/,$svn_ext_value)) {
my $svn_ext_external=$_;
#if you want some useful message uncoment print lines
#print "-----------------\n";
#print "External$svn_ext_count: $svn_ext_external\n";
$svn_ext_count++;
my @svn_ext_exter=split(/\s+/,$svn_ext_external);
#if you want some useful message uncoment print lines
#print "+++++++++++++++++++++\n";
#print "\tName: $svn_ext_exter[0]\n";
#print "\tUrl: $svn_ext_exter[1]\n";
if ( $svn_ext_exter[0] eq $svn_ext_link ) {
$svn_ext_exter[1]=$svn_ext_target;
$svn_ext_setprop="1";
}
$svn_ext_newexternal=$svn_ext_newexternal."$svn_ex t_exter[0] $svn_ext_exter[1]\n";
}


print "\n\n\n";
if ( $svn_ext_setprop eq "1" ) {
#if you want some useful message uncoment print lines
#print "Set svn:external\n";
#print "================\n";
#print "Key:$svn_ext_key\n\n";
#print "Value:\n";
#print "Tmpdir: $svn_ext_path\n";
#print $svn_ext_newexternal;
my $svn_ext_logmsg="Operation: Change svn:externals\nRepo path:
$svn_ext_url\n\nFrom:\n$svn_ext_value\nTo:\n$svn_e xt_newexternal\n";
#print "Log message: $svn_ext_logmsg";
$svn_ext_ctx->checkout($svn_ext_url, $svn_ext_path, "HEAD", $recursive);
$svn_ext_ctx->propset($svn_ext_name,$svn_ext_newexternal,$svn_e xt_path,$svn_ext_force);
svnsetlogmsg($svn_ext_ctx,$svn_ext_logmsg);
$svn_ext_ctx->commit($svn_ext_path, $recursive);
remove( \1, $svn_ext_path );
} else {
#if you want some useful message uncoment print lines
#print "Value:\n";
#print $svn_ext_value;
}
}

#This is equivalent of the example in the doc to set the message in a svn operation...
sub svnsetlogmsg {
my ($svn_log_ctx, $svn_set_log_mesg) = @_;
my $svn_set_log_msg_handler = sub {
my $stringptr = shift;
$$stringptr = $svn_set_log_mesg;
return 1;
};
$svn_log_ctx->log_msg($svn_set_log_msg_handler);
};






Hartigan wrote:
> Hi all,
> i'm working to create some perl scripts to make changes on a svn(subversion)
> respository. One of this script try to change a svn:external but i have
> a problem to do this with the propset().
>
> I have a testing repository with this path
>
> http://localhost/svn/testing/develop_area/mail
>
> under this directory there are two svn:externals:
>

[Big cut!!!]
>
> Anyone have an idea about this problem ?
> Any idea on how change a svn:externals via perl on a remote repository?
>
> Thank you



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Free Online Subversion Training - All About Subversion Hook Scripts george.powell@wandisco.com Java 0 05-12-2010 09:43 AM
Free Online Subversion Training - Introduction to Subversion forDevelopers george.powell@wandisco.com Java 5 04-30-2010 02:57 AM
using subversion bindings Munagala Ramanath Ruby 1 01-24-2008 05:54 PM
Correct newlines for Perl programs in subversion? Adam Funk Perl Misc 2 06-27-2007 04:24 PM
Tree view of directory while using Subversion James E Keenan Perl Misc 1 11-13-2005 07:14 PM



Advertisments