The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

SVN::Dump::Walker - A callback interface for SVN::Dump.

SYNOPSIS

Subclass SVN::Dump::Walker to perform some task. Moose is optional. This is an abbreviated version of SVN::Dump::AuthorExtractor:

        package SVN::Dump::AuthorExtractor;
        use Moose;
        extends qw(SVN::Dump::Walker);

        has authors => (
                is      => 'rw',
                isa     => 'HashRef[Str]',
                default => sub { {} }
        );

        sub on_revision {
                my ($self, $revision, $author, $date, $log_message) = @_;
                $author = "(no author)" unless defined $author and length $author;
                $self->authors()->{$author} = 1;
        }

        sub on_walk_done {
                my $self = shift;
                foreach my $author (sort keys %{$self->authors()}) {
                        print "$author = <$author\@" . $self->svn_dump()->uuid() . ">\n";
                }
        }

        1;

And the subclass is used. This is an abbreviated version of snauthors:

        my $replayer = SVN::Dump::AuthorExtractor->new(
                svn_dump_filename => "subversion.dump",
        );

        $replayer->walk();
        exit;

DESCRIPTION

SVN::Dump::Walker walks a Subversion dump with SVN::Dump, calling back specific methods for each record.

Construction

SVN::Dump::Walker takes a few basic constructor parameters.

svn_dump_filename should contain the name of a Subversion dump file. It's required.

include_regexp may contain a regular expression defining the directories and files to include in the walk. Those that don't match won't trigger callbacks. Optional.

Public Methods

walk

Start the walker's SVN::Dump loop. Callbacks will be produced until an error occurs or the file is completely traversed.

Callback Methods

on_walk_begin

An initial callback when walk() has begun.

Called with only one parameter, $self.

on_walk_done

A final callback when SVN::Dump is done and walk() is about to return.

Called with only one parameter, $self.

on_revision

Called whenever a new Subversion revision begins.

Called with five parameters: $self, the revision number, its author, the time the revision was committed ("svn:date" property), and the corresponding log message ("svn:log" property).

on_revision_done

Called whenever a Subversion revision has been committed.

Called with two parameters: $self and the revision number.

on_node_add

Called whenever SVN::Dump encounters an "add" action that is not a copy. For adds that are copies, see on_node_copy().

Called with five parameters: $self, the revision number, the path of the thing being added, the kind of thing being added ("file" or "dir"), and optionally the contents of the thing being added.

on_node_change

Called whenever SVN::Dump encounters a "change" action that is not a copy. For changes that are copies, see on_node_copy().

Called with five parameters: $self, the revision number, the path of the thing being changed, the kind of thing being changed ("file" or "dir"), and optionally the contents of the thing being changed.

on_node_replace

Called whenever SVN::Dump encounters a "replace" action that is not a copy. For replacements that are copies, see on_node_copy().

Called with five parameters: $self, the revision number, the path of the thing being replaced, the kind of thing being replaced ("file" or "dir"), and optionally the contents of the thing being replaced.

Subversion determines how "replace" differs from "change".

on_node_delete

Called whenever SVN::Dump encounters a "delete" action.

Called with three parameters: $self, the revision number, and the path of the thing being deleted.

on_node_copy

Called whenever SVN::Dump encounters an action that results from a copy. The original actions may be "add", "change" or "replace", but they're all considered copies if they have 'Node-copyfrom-path' information.

Called with seven parameters: $self, the revision number, the destination path, the kind of thing being copied ("file" or "dir"), the copy source revision, the copy source path, and optionally the contents of the thing being copied.

BUGS

on_node_copy() loses some data---whether the copy is the result of an addition, a change, or a replacement. This isn't significant for SVN::Dump::Walker's original purpose, but it could be for someone else's. Please submit a bug if your use case requires the additional information.

SEE ALSO

SVN::Dump - SVN::Dump::Walker uses SVN::Dump to parse Subversion dumps.

App::SnerpVortex - SVN::Dump::Walker is used extensively in Snerp Vortex.

SVN::Dump::AuthorExtractor and snauthors are full versions of the SYNOPSIS examples.

AUTHORS AND LICENSE

Snerp Vortex is Copyright 2010 by Rocco Caputo and contributors.

It is released under the same terms as Perl itself.