[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

SVN::Client -- determine recent interesting rev of file

From: Nik Clayton <nik_at_ngo.org.uk>
Date: 2006-07-06 14:30:40 CEST

Hi all,

I'm experimenting with the SVN::Client API with Perl.

One of the things I need to do is, given a repository path and a revision,
find the youngest revision in which the path was modified that is less than
or equal to the given revision.

For example, given /trunk/foo, changed in revs 1, 4, 7, 12, the following
would all hold true:

    irev('/trunk/foo', 3) == 1;
    irev('/trunk/foo', 4) == 4;
    irev('/trunk/foo', 11) == 7;

I know how to do this using SVN::Repos:

    # Get the revision root, step back one hop in the node history
    # (which might be the same rev if it's interesting), and return
    # the revision at that hop.
    #
    # $repo = SVN::Repos object
    sub irev {
        my($path, $rev) = @_;

        my $fs = $repo->fs();
        my $root = $fs->revision_root($rev);
        my $hist = $root->node_history($path);
        $hist = $hist->prev(0);

        return ($hist->location())[1];
    }

and using SVN::Ra:

    # Get the logs for this path, starting at $rev. Set limit to
    # 1 so that the callback is only called once. In the callback
    # assign the log's revision number to the variable we're going
    # to return.
    #
    # $ra = SVN::Ra object
    sub irev {
        my($path, $rev) = @_

        $ra->get_log([$path], $rev, 1, 1, 0, 1,
                     sub { $rev = $_[1] });

        return $rev;
    }

I can't see how it would work with SVN::Client. I can't use
SVN::Client::get_logs(), as that doesn't have a $limit parameter.

I've tried using SVN::Client::ls() and calling the created_rev() method of
the dirent that's returned. However, this has the same problem that I
discussed in:

   http://subversion.tigris.org/servlets/ReadMsg?list=dev&msgNo=117167

Specifically, the created_rev() for a node that's been copied is normally
the revision in which the source of the copy was last changed, not the
revision in which the copy happened.

Is this possible?

N

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Jul 6 23:08:37 2006

This is an archived mail posted to the Subversion Dev mailing list.