App-KGB
view release on metacpan or search on metacpan
lib/App/KGB/Client/Subversion.pm view on Meta::CPAN
$client->run;
=head1 DESCRIPTION
B<App::KGB::Client::Subversion> provides Subversion-specific retrieval of
commits and changes for L<App::KGB::Client>.
=head1 CONSTRUCTOR
=head2 B<new> ( { initializers } )
Standard constructor. Accepts inline hash with initial field values.
=head1 FIELDS
App:KGB::Client::Subversion defines two additional fields:
=over
=item B<repo_path> (B<mandatory>)
Physical path to Subversion repository.
=item B<revision>
The revision about which to notify. If omitted defaults to the last revision
of the repository.
=back
=head1 METHODS
=over
=item describe_commit
The first time this method is called, it retrieves commit number and repository
path from command-line parameters and returns an instance of
L<App::KGB::Commit> class describing the commit.
All subsequential invocations return B<undef>.
=back
=cut
require v5.10.0;
use base 'App::KGB::Client';
use App::KGB::Change;
use App::KGB::Commit;
use Carp qw(confess);
use SVN::Core;
use SVN::Fs;
use SVN::Repos;
__PACKAGE__->mk_accessors(qw( _called repo_path revision ));
use constant rev_prefix => 'r';
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
$self->_called(0);
defined( $self->repo_path )
or confess "'repo_path' is mandatory";
return $self;
}
sub describe_commit {
my ($self) = @_;
return undef if $self->_called;
my ( $author, $log, @changes );
# Shut up the perl compiler warnings
if ( $SVN::Fs::PathChange::modify
and $SVN::Fs::PathChange::add
and $SVN::Fs::PathChange::delete
and $SVN::Fs::PathChange::replace )
{
}
my $repo = SVN::Repos::open( $self->repo_path );
my $fs = $repo->fs or die $!;
$self->revision( $fs->youngest_rev ) unless defined( $self->revision );
$log = $fs->revision_prop( $self->revision, "svn:log" );
$author = $fs->revision_prop( $self->revision, "svn:author" );
my $root = $fs->revision_root( $self->revision );
my $changed = $root->paths_changed();
foreach ( keys %$changed ) {
my $k = $changed->{$_}->change_kind();
if ( $k == $SVN::Fs::PathChange::modify ) {
$k = "M";
}
elsif ( $k == $SVN::Fs::PathChange::add ) {
$k = "A";
}
elsif ( $k == $SVN::Fs::PathChange::delete ) {
$k = "D";
}
elsif ( $k == $SVN::Fs::PathChange::replace ) {
$k = "R";
}
my $pm = $changed->{$_}->prop_mod();
push @changes,
App::KGB::Change->new(
{ action => $k,
prop_change => $pm,
path => $_,
}
);
}
$self->_called(1);
( run in 0.989 second using v1.01-cache-2.11-cpan-5b529ec07f3 )