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

Discussion in 'Perl Misc' started by david.karr, Jun 10, 2010.

  1. david.karr

    david.karr Guest

    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?
     
    david.karr, Jun 10, 2010
    #1
    1. Advertising

  2. david.karr

    david.karr Guest

    On Jun 10, 10:03 am, Ben Morrow <> wrote:
    > Quoth "david.karr" <>:
    >
    > > 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";
    }
    }
    ----------------
     
    david.karr, Jun 10, 2010
    #2
    1. Advertising

  3. david.karr

    Guest

    On Thu, 10 Jun 2010 13:00:25 -0700 (PDT), "david.karr" <> wrote:

    >On Jun 10, 10:03 am, Ben Morrow <> wrote:
    >> Quoth "david.karr" <>:
    >>
    >> > 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
     
    , Jun 10, 2010
    #3
  4. david.karr

    Guest

    On Thu, 10 Jun 2010 14:02:21 -0700, wrote:

    >On Thu, 10 Jun 2010 13:00:25 -0700 (PDT), "david.karr" <> 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
     
    , Jun 10, 2010
    #4
  5. david.karr

    John Bokma Guest

    OT: Version control (was: How to get "last action" from SVN::Client?)

    Ben Morrow <> 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
     
    John Bokma, Jun 11, 2010
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. kj12345

    Refresh repeats last action

    kj12345, Sep 28, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    517
    Eliyahu Goldin
    Sep 29, 2004
  2. Alessandro Rossi

    get svn version

    Alessandro Rossi, Jun 6, 2005, in forum: Java
    Replies:
    7
    Views:
    13,050
    Alessandro Rossi
    Jun 7, 2005
  3. gert
    Replies:
    3
    Views:
    1,013
  4. Jan Burse
    Replies:
    9
    Views:
    1,803
    Jan Burse
    May 8, 2012
  5. Replies:
    0
    Views:
    538
Loading...

Share This Page