You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Mike Schilli <m...@perlmeister.com> on 2009/10/05 22:43:48 UTC

Limit svnlook history output?

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@perlmeister.com

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

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

Re: Limit svnlook history output?

Posted by Lorenz <lo...@yahoo.com>.
Mike Schilli wrote:
[...]
>While
>
>     /home/y/bin/svnlook history -r 3157 /path/to/repo file
>
>finds a file deleted in revision 3158,
>
>     /home/y/bin/svn info -r 3157 file:///path/to/repo/file
>
>reports
>
>     svn: File not found: revision 3158, path '/file'
>
>Any way around that?

svn info file:///path/to/repo/file@3157


for information about peg revision see

 http://svnbook.red-bean.com/nightly/en/svn.advanced.pegrevs.html
-- 
Lorenz

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

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

Re: Limit svnlook history output?

Posted by Mike Schilli <m...@perlmeister.com>.
On Wed, 7 Oct 2009, David Weintraub wrote:

> To get around this, you also have to use 'pegging' to specify the
> revision of the URL too: 
> $ svn info -r$PREV_REV svn://project/trunk/deleted_file.txt@$PREV_REV

Works like a charm, thanks! And I guess it's safe to leave the 'peg' in
there, even for updated or added files as well.

-- Mike

Mike Schilli
m@perlmeister.com

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

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

Re: Limit svnlook history output?

Posted by David Weintraub <qa...@gmail.com>.
Things get a bit messier if you have deleted.

When a file is deleted, you not only need to look at the previous revision
to find the last changed revision for that file, you also have to "peg" the
file's URL with that revision too. Obviously, this won't work:*

**$ svn info -r$CURRENT_REV svn://project/trunk/deleted_file.txt*

since that file doesn't exist. But, this won't work either:

*$ svn info -r$PREV_REV **svn://project/trunk/deleted_file.txt*

since the URL to the deleted file is referring to the URL in the CURRENT
revision of the repository, and there is no "deleted_file.txt" in that
revision of the repository.

To get around this, you also have to use 'pegging' to specify the revision
of the URL too:

*$ svn info -r$PREV_REV **svn://project/trunk/deleted_file.txt@$PREV_REV*

Now, you're referring to the file's URL in the previous revision before it
was deleted. Yes,  it seems strange you have to specify the revision in two
different places, but one is the revision of that file, and the other is the
URL revision.

On Tue, Oct 6, 2009 at 2:49 PM, Mike Schilli <m...@perlmeister.com> wrote:

> On Tue, 6 Oct 2009, Mike Schilli wrote:
>
>  *$ svn info -r59999
>>> http://subversion/dev/modules/foo/trunk/build.xml*
>>>
>> Sweetness, that's exactly what I want! Using a "file:///" URL lets me
>> use the local file system and the "Last Changed Rev: nnnn" entry
>> contains the last repo revision before 59999 that contains a change for
>> the specified file.
>>
>
> Hmm, looks like I spoke too soon: While this works well with added and
> updated files, it won't find files that have been deleted in the
> previous transaction.
>
> While
>
>    /home/y/bin/svnlook history -r 3157 /path/to/repo file
>
> finds a file deleted in revision 3158,
>
>    /home/y/bin/svn info -r 3157 file:///path/to/repo/file
>
> reports
>
>    svn: File not found: revision 3158, path '/file'
>
> Any way around that?
>
>
> -- Mike
>
> Mike Schilli
> m@perlmeister.com
>
>
>> Thanks much for your help.
>>
>> -- Mike
>>
>> Mike Schilli
>> m@perlmeister.com
>>
>>
>>> Once you get what you're looking for, you can put that into the "svn log"
>>> command:
>>>
>>> *
>>> **$ svn log -r$lastChgRev:$firstChgRev
>>> http://subversion/dev/modules/foo/trunk/build.xml*
>>>
>>
>>
>>>
>>> On Mon, Oct 5, 2009 at 6:43 PM, Mike Schilli <m...@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@perlmeister.com
>>>>
>>>> ------------------------------------------------------
>>>>
>>>>
>>>> http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2403903
>>>>
>>>> To unsubscribe from this discussion, e-mail: [
>>>> users-unsubscribe@subversion.tigris.org].
>>>>
>>>>
>>>
>>>
>>> --
>>> David Weintraub
>>> qazwart@gmail.com
>>>
>>>
>>


-- 
David Weintraub
qazwart@gmail.com

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

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

Re: Limit svnlook history output?

Posted by Mike Schilli <m...@perlmeister.com>.
On Tue, 6 Oct 2009, Mike Schilli wrote:

>> *$ svn info -r59999
>> http://subversion/dev/modules/foo/trunk/build.xml*
> Sweetness, that's exactly what I want! Using a "file:///" URL lets me
> use the local file system and the "Last Changed Rev: nnnn" entry
> contains the last repo revision before 59999 that contains a change for
> the specified file.

Hmm, looks like I spoke too soon: While this works well with added and
updated files, it won't find files that have been deleted in the
previous transaction.

While

     /home/y/bin/svnlook history -r 3157 /path/to/repo file

finds a file deleted in revision 3158,

     /home/y/bin/svn info -r 3157 file:///path/to/repo/file

reports

     svn: File not found: revision 3158, path '/file'

Any way around that?

-- Mike

Mike Schilli
m@perlmeister.com

>
> Thanks much for your help.
>
> -- Mike
>
> Mike Schilli
> m@perlmeister.com
>
>> 
>> Once you get what you're looking for, you can put that into the "svn log"
>> command:
>> 
>> *
>> **$ svn log -r$lastChgRev:$firstChgRev
>> http://subversion/dev/modules/foo/trunk/build.xml*
>
>> 
>> 
>> On Mon, Oct 5, 2009 at 6:43 PM, Mike Schilli <m...@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@perlmeister.com
>>> 
>>> ------------------------------------------------------
>>> 
>>> http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2403903
>>> 
>>> To unsubscribe from this discussion, e-mail: [
>>> users-unsubscribe@subversion.tigris.org].
>>> 
>> 
>> 
>> 
>> --
>> David Weintraub
>> qazwart@gmail.com
>> 
>

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

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

Re: Limit svnlook history output?

Posted by Mike Schilli <m...@perlmeister.com>.
On Tue, 6 Oct 2009, David Weintraub wrote:

> *svnlook history $repos $path | while read revision path

Hmm, this doesn't really accomplish what I want, as 'svnlook history' will
still waste cycles generating potentially thousands of entries, which are
then thrown away on the other wend of the pipe.

> *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*

Sweetness, that's exactly what I want! Using a "file:///" URL lets me
use the local file system and the "Last Changed Rev: nnnn" entry
contains the last repo revision before 59999 that contains a change for
the specified file.

Thanks much for your help.

-- Mike

Mike Schilli
m@perlmeister.com

>
> Once you get what you're looking for, you can put that into the "svn log"
> command:
>
> *
> **$ svn log -r$lastChgRev:$firstChgRev
> http://subversion/dev/modules/foo/trunk/build.xml*

>
>
> On Mon, Oct 5, 2009 at 6:43 PM, Mike Schilli <m...@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@perlmeister.com
>>
>> ------------------------------------------------------
>>
>> http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2403903
>>
>> To unsubscribe from this discussion, e-mail: [
>> users-unsubscribe@subversion.tigris.org].
>>
>
>
>
> --
> David Weintraub
> qazwart@gmail.com
>

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

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

Re: Limit svnlook history output?

Posted by David Weintraub <qa...@gmail.com>.
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
do
    [ "$revision" = "REVISION" ] && continue #Skip header
    [ "$revision" = "---------" ] && continue
    <do something>
    [ $flag = "endloop" ] && break #Found what I want
done
*

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
parameter:

*$ 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"
command:

*
**$ svn log -r$lastChgRev:$firstChgRev
http://subversion/dev/modules/foo/trunk/build.xml*


On Mon, Oct 5, 2009 at 6:43 PM, Mike Schilli <m...@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@perlmeister.com
>
> ------------------------------------------------------
>
> http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2403903
>
> To unsubscribe from this discussion, e-mail: [
> users-unsubscribe@subversion.tigris.org].
>



-- 
David Weintraub
qazwart@gmail.com

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

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