Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Subversion: last change author

by water (Deacon)
on Oct 27, 2006 at 01:52 UTC ( #580854=perlquestion: print w/ replies, xml ) Need Help??
water has asked for the wisdom of the Perl Monks concerning the following question:

Hi --

I am looking for a way from w/in a perl program to determine, for a given file in a subversion repository, the last person who committed a change to that file. Any suggestions or module recommendations much appreciated.

Thanks!

water

Comment on Subversion: last change author
Re: Subversion: last change author
by imp (Priest) on Oct 27, 2006 at 02:19 UTC
      Thanks!

      SVNLook seems to take a version perspective on the tree -- how get a file perspective?

      Rather than "which author made the last revision to the repository, and which files were involved", I'm looking to determine "which author made the most recent change to file 'x', and when was that change made".

      Can SVNLook do that, or did I misread the docs?

      Thanks!!

Re: Subversion: last change author
by brian_d_foy (Abbot) on Oct 27, 2006 at 05:10 UTC

    I have this little script, although it shells out to svn log to ask it about the file. It's good enough for the rare times when I need it and don't want to look at svn log directly.

    #!/usr/bin/perl foreach $f (@ARGV) { open F, "svn log $f |"; while(<F>) { next unless /^r/; /^(r\d+)\s+\|\s+(.*?)\s+\|/; print "$f $1 $2\n"; last } close F or do { $! = $? >> 8; warn "Could not read $f: $!" }; }

    The output shows me the file, last revision where the file was changed, and who changed it. With a little more work I could get the date (or just print the entire second line from svn log).

    $ svn-who Chap*/*.pod ... Chapters/16.tied_variables.pod r137 brian Chapters/17.modulinos.pod r130 brian Chapters/18.bit_vectors.pod r137 brian Chapters/19.foriegn_relations.pod r137 brian
    --
    brian d foy <brian@stonehenge.com>
    Subscribe to The Perl Review
Re: Subversion: last change author
by Fletch (Chancellor) on Oct 27, 2006 at 12:25 UTC

    An svn ls -v file should show the last author and revision of the last commit for a given file (among other things; see svn help ls). You can run that through a piped open or backticks, or see if the module referenced previously gives a way to do that.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://580854]
Approved by Moriarty
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2014-09-23 04:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (210 votes), past polls