Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > How to get "last action" from SVN::Client?

Reply
Thread Tools

How to get "last action" from SVN::Client?

 
 
david.karr
Guest
Posts: n/a
 
      06-10-2010
I've used TortoiseSVN to get all the history entries for a branch.
Each entry has a "last action", indicating "added", "modified", or
"deleted". I'd like to have a Perl script using SVN::Client (or any
other appropriate module) generate this output instead. I've used the
"log" method of SVN::Client, and I've read through the SVN::Client
documentation, but I don't see any way to get this information. The
only reference in the documentation to one of "Add", "Modify", or
"Delete" is when committing a change. What am I missing?
 
Reply With Quote
 
 
 
 
david.karr
Guest
Posts: n/a
 
      06-10-2010
On Jun 10, 10:03*am, Ben Morrow <(E-Mail Removed)> wrote:
> Quoth "david.karr" <(E-Mail Removed)>:
>
> > I've used TortoiseSVN to get all the history entries for a branch.
> > Each entry has a "last action", indicating "added", "modified", or
> > "deleted". *I'd like to have a Perl script using SVN::Client (or any
> > other appropriate module) generate this output instead. *I've used the
> > "log" method of SVN::Client, and I've read through the SVN::Client
> > documentation, but I don't see any way to get this information. *The
> > only reference in the documentation to one of "Add", "Modify", or
> > "Delete" is when committing a change. *What am I missing?

>
> The SVN::Client->log method passes a svn_log_changed_path_t object[0] to
> its callback; this is documented in SVN::Core and tells you what changed
> in that revision.


Ok, that looks promising. However, when I code this, it seems like
that hash is always empty.

Does it matter that the server is SVN 1.4.x?

This is an excerpt from my script:
-----------------
my $ctx = new SVN::Client(auth =>
[SVN::Client::get_simple_provider()]);

my @revisionsList;

$ctx->log([$opt_element], 1, "HEAD", 1, 0, \&addToRevisionsList);

sub addToRevisionsList($$$$$$) {
my ($changed_paths, $revision, $author, $date, $message, $pool) =
@_;
print "revision[$revision] author[$author] date[$date]
message[$message]\n";
print "changed_paths[$changed_paths] size[" .
keys(%changed_paths) . "]\n";
while(($key, $value) = each(%changed_paths)) {
print "key[$key]\n";
}
}
----------------
 
Reply With Quote
 
 
 
 
sln@netherlands.com
Guest
Posts: n/a
 
      06-10-2010
On Thu, 10 Jun 2010 13:00:25 -0700 (PDT), "david.karr" <(E-Mail Removed)> wrote:

>On Jun 10, 10:03*am, Ben Morrow <(E-Mail Removed)> wrote:
>> Quoth "david.karr" <(E-Mail Removed)>:
>>
>> > I've used TortoiseSVN to get all the history entries for a branch.
>> > Each entry has a "last action", indicating "added", "modified", or
>> > "deleted". *I'd like to have a Perl script using SVN::Client (or any
>> > other appropriate module) generate this output instead. *I've used the
>> > "log" method of SVN::Client, and I've read through the SVN::Client
>> > documentation, but I don't see any way to get this information. *The
>> > only reference in the documentation to one of "Add", "Modify", or
>> > "Delete" is when committing a change. *What am I missing?

>>
>> The SVN::Client->log method passes a svn_log_changed_path_t object[0] to
>> its callback; this is documented in SVN::Core and tells you what changed
>> in that revision.

>
>Ok, that looks promising. However, when I code this, it seems like
>that hash is always empty.
>
>Does it matter that the server is SVN 1.4.x?
>
>This is an excerpt from my script:
>-----------------
>my $ctx = new SVN::Client(auth =>
>[SVN::Client::get_simple_provider()]);
>
>my @revisionsList;
>
>$ctx->log([$opt_element], 1, "HEAD", 1, 0, \&addToRevisionsList);
>
>sub addToRevisionsList($$$$$$) {
> my ($changed_paths, $revision, $author, $date, $message, $pool) =
>@_;
> print "revision[$revision] author[$author] date[$date]
>message[$message]\n";
> print "changed_paths[$changed_paths] size[" .
>keys(%changed_paths) . "]\n";
> while(($key, $value) = each(%changed_paths)) {
> print "key[$key]\n";
> }
>}
>----------------

"If $changed_paths is defined it references a hash"

so $changed_paths is a hash "reference", you must dereference
it to get the key values. %{$changed_paths}.

use strict;
use warnings;

my $ref = {'a','b', 'c','d'};

while (my ($key, $val) = each %$ref) {
print "$key = $val\n";
}

-sln
 
Reply With Quote
 
sln@netherlands.com
Guest
Posts: n/a
 
      06-10-2010
On Thu, 10 Jun 2010 14:02:21 -0700, http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

>On Thu, 10 Jun 2010 13:00:25 -0700 (PDT), "david.karr" <(E-Mail Removed)> wrote:
>
>>keys(%changed_paths) . "]\n";


If you want to print the key/val's:
print "@{[%$changed_paths]}\n";
or, just the keys
print "@{[keys %$changed_paths]}\n";

Note, its inside quotes "".

-sln
 
Reply With Quote
 
John Bokma
Guest
Posts: n/a
 
      06-10-2010
Ben Morrow <(E-Mail Removed)> writes:

> I've no idea, I'm afraid. I haven't used SVN for quite some time,


Did you migrate to git, and if yes was it an easy migration. As in
migrating the repositories and migrating to the new tool chain?

If not git, I am curious as well.

I use mainly subversion but want to look more into git. I know that
which vc is somewhat a matter of taste, but IMO it doesn't hurt to use
another one for a while.

Thanks,

--
John Bokma j3b

Hacking & Hiking in Mexico - http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Serious cache problem - Page_Load get never get called !!! Ryan Park ASP .Net 2 01-03-2005 05:52 PM
Re: use anonymous but get get an authentication box Curt_C [MVP] ASP .Net 2 09-21-2004 06:39 PM
use anonymous but get get an authentication box =?Utf-8?B?U2hhcmlm?= ASP .Net 0 09-21-2004 01:01 PM



Advertisments