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

Discussion in 'Perl Misc' started by Hartigan, Nov 2, 2009.

  1. Hartigan

    Hartigan Guest

    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/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 ?
    Any idea on how change a svn:externals via perl on a remote repository?

    Thank you
    Hartigan, Nov 2, 2009
    #1
    1. Advertising

  2. Hartigan

    Hartigan Guest

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






    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
    Hartigan, Nov 9, 2009
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Harry George

    python under subversion (svn)

    Harry George, Apr 27, 2004, in forum: Python
    Replies:
    3
    Views:
    306
    Harry George
    Apr 28, 2004
  2. Mike B
    Replies:
    2
    Views:
    653
    Mike B
    Aug 29, 2008
  3. Replies:
    5
    Views:
    732
    John B. Matthews
    Apr 30, 2010
  4. Replies:
    0
    Views:
    363
  5. Rob Muhlestein
    Replies:
    0
    Views:
    73
    Rob Muhlestein
    Dec 30, 2006
Loading...

Share This Page