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

View: New views
5 Messages — Rating Filter:   Alert me  

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

by IPv7 Develop Group :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,
i'm working to create some perl scripts to make changes on a svn(subversion)
repository. 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/mail/branches/maintenance-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/mail/branches/maintenance-release-1.64
develop http://localhost/svn/testing/main/mail/trunk

-----------------
External1: stable
http://localhost/svn/testing/main/mail/branches/maintenance-release-1.64
+++++++++++++++++++++
        Name: stable
        Url:
http://localhost/svn/testing/main/mail/branches/maintenance-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/mail/branches/maintenance-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 ? Need i to open a bug ?
Any idea on how change a svn:externals via perl on a remote repository?

Thank you

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2414022

To unsubscribe from this discussion, e-mail: [users-unsubscribe@...].

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

by Christian Unger-7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 03.11.2009, at 08:15, IPv7 Develop Group wrote:

> Setting property on non-local target


you are trying to set the svn:external property on a remote target  
that is inside the repository,
afaik subversion only supports setting the svn:external property on a  
working copy (a local target).


Try using --depth=empty when you checkout – this way you will only get  
the directory containing the definitions.


hth
__
cu
christian unger

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2414029

To unsubscribe from this discussion, e-mail: [users-unsubscribe@...].

smime.p7s (3K) Download Attachment

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

by IPv7 Develop Group :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Christian Unger wrote:
> On 03.11.2009, at 08:15, IPv7 Develop Group wrote:
>
>> Setting property on non-local target
>
>
> you are trying to set the svn:external property on a remote target that is inside the repository,
> afaik subversion only supports setting the svn:external property on a working copy (a local target).

svn propedit svn:externals http://localhost/svn/testing/develop_area/mail/
work fine without no working copy, this is a operation on the repository directly...

> Try using --depth=empty when you checkout – this way you will only get  
> the directory containing the definitions.

So need i to checkout, change the working copy and then commit the change, a svn:external?
The only way i see is to wrap the svn shell command in perl and remove all the SVN::Client reference,
because this implementation isn't oriented for the scripting...

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2414030

To unsubscribe from this discussion, e-mail: [users-unsubscribe@...].

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

by Ryan Schmidt-60 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Nov 3, 2009, at 02:19, IPv7 Develop Group wrote:

> Christian Unger wrote:
>
>> you are trying to set the svn:external property on a remote target  
>> that is inside the repository,
>> afaik subversion only supports setting the svn:external property on  
>> a working copy (a local target).
>
> svn propedit svn:externals http://localhost/svn/testing/develop_area/mail/
> work fine without no working copy, this is a operation on the  
> repository directly...

That is correct. "svn propedit" works on remote URLs, but "svn  
propset" does not. Please see:

http://subversion.tigris.org/issues/show_bug.cgi?id=2238#desc10


>> Try using --depth=empty when you checkout – this way you will only  
>> get
>> the directory containing the definitions.
>
> So need i to checkout, change the working copy and then commit the  
> change, a svn:external?

Yes.

> The only way i see is to wrap the svn shell command in perl and  
> remove all the SVN::Client reference,
> because this implementation isn't oriented for the scripting...

I'm not sure what you mean.

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2415691

To unsubscribe from this discussion, e-mail: [users-unsubscribe@...].

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

by IPv7 Develop Group :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ryan Schmidt wrote:
> On Nov 3, 2009, at 02:19, IPv7 Develop Group wrote:
>
>> Christian Unger wrote:
[Cut..]
> That is correct. "svn propedit" works on remote URLs, but "svn  
> propset" does not. Please see:
>
> http://subversion.tigris.org/issues/show_bug.cgi?id=2238#desc10

Thank you for the info about it. You know if this change will be included in the SVN::Client?

>> So need i to checkout, change the working copy and then commit the  
>> change, a svn:external?
>
> Yes.

At the end of the email i paste some lines code in perl to make this,
if someone need it and don't want to spend time, is a base to understand how make it.


>> The only way i see is to wrap the svn shell command in perl and  
>> remove all the SVN::Client reference,
>> because this implementation isn't oriented for the scripting...
>
> I'm not sure what you mean.

Sorry, i wrote this because i lost some times to understand why the function to change a prop is so difficult to
implement in a script to make some operation without the human presence... ;)


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_ext_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_ext_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_ext_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);
};

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2415788

To unsubscribe from this discussion, e-mail: [users-unsubscribe@...].