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

Re: Limit svnlook history output?

From: David Weintraub <qazwart_at_gmail.com>
Date: Tue, 6 Oct 2009 11:15:34 -0400

If you're using bash, you can put the output of the svnlook history command
in a while loop and exit the loop when you're done:

*svnlook history $repos $path | while read revision path
    [ "$revision" = "REVISION" ] && continue #Skip header
    [ "$revision" = "---------" ] && continue
    <do something>
    [ $flag = "endloop" ] && break #Found what I want

You should be able to do the same thing in Perl or Python -- especially if
you use the API.

Of course, nothing says you have to use "svnlook" when you're looking at an
actual revision instead of just the current commit transaction. You can use
the "svn" command which has many more options and parameters. What you
cannot do is use "svn" with a workspace (you don't have one, and you don't
want to create one). But, as long as the arguments are with the Subversion
URL, you're fine.

With the standard "svn" command, you can get the previous changed revision,
and then from that, get the changed revision before that one. For example,
to get the first changed revision, use "svn info" without the revision

*$ svn info http://subversion/dev/modules/foo/trunk/build.xml
*Then subtract one from that revision number, and put it into the next "svn
info" command. Let's say the above said the last changed revision for
build.xml was revision 60,000. I can do the same command for revision 59,999
and see what was the last changed revision before revision 60,000:

*$ svn info -r59999 http://subversion/dev/modules/foo/trunk/build.xml*

Once you get what you're looking for, you can put that into the "svn log"

**$ svn log -r$lastChgRev:$firstChgRev

On Mon, Oct 5, 2009 at 6:43 PM, Mike Schilli <m_at_perlmeister.com> wrote:

> In a post_commit hook, 'svnlook history' can be used to dig up details
> on the previous checkin of the affected file(s).
> Running
> svnlook history -r txn repo path
> returns a list of N historical entries of which the 2nd one is the repo
> on the previous repo version of the same file.
> Questions:
> a) Is this the best way of obtaining the first repo revision containing
> the previous version of the file?
> b) Is there a way to limit the output to a small number of entries? Some
> files have histories of several thousand entries, most of which aren't
> needed in this case.
> Any help appreciated!
> -- Mike
> Mike Schilli
> m_at_perlmeister.com
> ------------------------------------------------------
> http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2403903
> To unsubscribe from this discussion, e-mail: [
> users-unsubscribe_at_subversion.tigris.org].

David Weintraub
To unsubscribe from this discussion, e-mail: [users-unsubscribe_at_subversion.tigris.org].
Received on 2009-10-06 17:16:36 CEST

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