You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by "Christopher H. Laco" <cl...@chrislaco.com> on 2005/11/17 02:28:04 UTC

Getting Knowhere in Perl

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm still getting absolutely nowhere using the Perl API to get a files'
contents and log entries on copy revisions of files just like
svn cat [-r] url  does. All I can do now is resort to bribery. :-)

I offer a free O'Reilly book of your choosing to the first person who
can spend some time off-list and help me understand the subversion API
enough to get it done.

Somewhare more to my problem, I'm trying to replicate how this command
works:

svn cat -r871  http://handelframework.com/svn/CPAN/Handel/tags/0.24/Changes


I can see from the logs that at some point we request the path from
tags/0.24, and at the end we request the specified revision from trunk..

What's not clear to me is how to resolve patsh of copies to their
original locations using the SVN::Ra or SVN::Client API....

>"PROPFIND /svn/CPAN/Handel/tags/0.24/Changes HTTP/1.1" 207 690 "-" "SVN/1.2.0 (r14790) neon/0.24.7"
>"PROPFIND /svn/!svn/vcc/default HTTP/1.1" 207 390 "-" "SVN/1.2.0 (r14790) neon/0.24.7"
>"PROPFIND /svn/!svn/bln/923 HTTP/1.1" 207 445 "-" "SVN/1.2.0 (r14790) neon/0.24.7"
>"PROPFIND /svn/CPAN/Handel/tags/0.24/Changes HTTP/1.1" 207 690 "-" "SVN/1.2.0 (r14790) neon/0.24.7"
>"PROPFIND /svn/!svn/vcc/default HTTP/1.1" 207 390 "-" "SVN/1.2.0 (r14790) neon/0.24.7"
>"PROPFIND /svn/!svn/bln/923 HTTP/1.1" 207 445 "-" "SVN/1.2.0 (r14790) neon/0.24.7"
>"PROPFIND /svn/CPAN/Handel/tags/0.24/Changes HTTP/1.1" 207 690 "-" "SVN/1.2.0 (r14790) neon/0.24.7"
>"PROPFIND /svn/!svn/vcc/default HTTP/1.1" 207 445 "-" "SVN/1.2.0 (r14790) neon/0.24.7"
>"REPORT /svn/!svn/bc/923/CPAN/Handel/tags/0.24/Changes HTTP/1.1" 200 178 "-" "SVN/1.2.0 (r14790) neon/0.24.7"
>"PROPFIND /svn/CPAN/Handel/trunk/Changes HTTP/1.1" 207 682 "-" "SVN/1.2.0 (r14790) neon/0.24.7"
>"PROPFIND /svn/!svn/vcc/default HTTP/1.1" 207 445 "-" "SVN/1.2.0 (r14790) neon/0.24.7"
>"PROPFIND /svn/!svn/bc/871/CPAN/Handel/trunk/Changes HTTP/1.1" 207 694 "-" "SVN/1.2.0 (r14790) neon/0.24.7"
>"PROPFIND /svn/CPAN/Handel/trunk/Changes HTTP/1.1" 207 682 "-" "SVN/1.2.0 (r14790) neon/0.24.7"
>/svn/!svn/vcc/default HTTP/1.1" 207 445 "-" "SVN/1.2.0 (r14790) neon/0.24.7"
>"PROPFIND /svn/!svn/bc/871/CPAN/Handel/trunk/Changes HTTP/1.1" 207 1583 "-" "SVN/1.2.0 (r14790) neon/0.24.7"
>"PROPFIND /svn/CPAN/Handel/trunk/Changes HTTP/1.1" 207 682 "-" "SVN/1.2.0 (r14790) neon/0.24.7"
>"PROPFIND /svn/!svn/vcc/default HTTP/1.1" 207 445 "-" "SVN/1.2.0 (r14790) neon/0.24.7"
>"PROPFIND /svn/!svn/bc/871/CPAN/Handel/trunk/Changes HTTP/1.1" 207 465 "-" "SVN/1.2.0 (r14790) neon/0.24.7"
>"GET /svn/!svn/bc/871/CPAN/Handel/trunk/Changes HTTP/1.1" 200 12807 "-" "SVN/1.2.0 (r14790) neon/0.24.7"


Any takers?

- -=Chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFDe+q0+66dLHM50ssRAufqAKCPyt5JHHZQhtaSZ8dtpl8eqDHejQCeMgty
Kj+WRpzVstOuxSv0ijeNWew=
=QnQI
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Getting Knowhere in Perl

Posted by "Christopher H. Laco" <cl...@chrislaco.com>.
Gerard Gerritsen wrote:
> Hello,
> 
> another update :)
> 
> looks like the code handles replaces a bit weird
> 
>  R /branches/ruby/doc/tools/dtd/docbook41/ent/iso-amsa.ent
>          Copied from : /trunk/doc/tools/dtd/docbook41/ent/iso-amsa.ent (13505)
>  R /branches/ruby/doc/tools/fo-stylesheet.xsl
>          Copied from : /trunk/doc/tools/fo-stylesheet.xsl (13505)
> 
> new version says
>  M /branches/locking/subversion/clients/cmdline/export-cmd.c
>  R /branches/locking/subversion/clients/cmdline/dtd/log.dtd
>          Replaced from  : /trunk/subversion/clients/cmdline/dtd/log.dtd (12893)
>  A /branches/locking/subversion/clients/cmdline/dtd
>          Copied from : /trunk/subversion/clients/cmdline/dtd (12893)
> 
> 

So, based on the tinkering, it appears the the only safe way to get the
contents for a url is:

walk the log tree from the request revision till a copy/replace event,
then request the file from the original location [using any revision at
that point)

using the Ra instead of Client, I guess even better is to do:

checkpath with request url and revision
if it exists, simply cat using url/rev

if it doesn't exists, walk the log tree again, and fid the original
location. request the original location at the requested revision


My braind hurts.. :-)

-=Chris

Re: Getting Knowhere in Perl

Posted by Gerard Gerritsen <si...@gmail.com>.
Hello,

another update :)

looks like the code handles replaces a bit weird

 R /branches/ruby/doc/tools/dtd/docbook41/ent/iso-amsa.ent
         Copied from : /trunk/doc/tools/dtd/docbook41/ent/iso-amsa.ent (13505)
 R /branches/ruby/doc/tools/fo-stylesheet.xsl
         Copied from : /trunk/doc/tools/fo-stylesheet.xsl (13505)

new version says
 M /branches/locking/subversion/clients/cmdline/export-cmd.c
 R /branches/locking/subversion/clients/cmdline/dtd/log.dtd
         Replaced from  : /trunk/subversion/clients/cmdline/dtd/log.dtd (12893)
 A /branches/locking/subversion/clients/cmdline/dtd
         Copied from : /trunk/subversion/clients/cmdline/dtd (12893)


#!/usr/bin/perl

use SVN::Client;

use warnings;
use strict;
my $ctx = SVN::Client->new;

die "no url given" unless $ARGV[0];
my $a = $ctx->url_from_path($ARGV[0]);

print "Scanning $a\n";
sub receiver
{
    my ($changed_paths, $revision, $author, $data, $message) = @_;
    print "\n$revision $author $data $message\n";
    if (defined $changed_paths)
    {
        foreach my $path (keys %{$changed_paths})
        {
            my $obj = $changed_paths->{$path};

            print "\t\n ".$obj->action." $path ";
            my $msg = $obj->action eq 'R' ? 'Replaced from ' : 'Copied from';

            if (defined $obj->copyfrom_path)
            {
                print "\n\t $msg : ".$obj->copyfrom_path ." (".
$obj->copyfrom_rev.")";
             }

        }
    }
    print "\n";
}

print $ctx->log($a,'HEAD',1, 1,0 , \&receiver);
exit 0

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org