SVN-S4

 view release on metacpan or  search on metacpan

lib/SVN/S4.pm  view on Meta::CPAN

# See copyright, etc in below POD section.
######################################################################

package SVN::S4;
require 5.006_001;
use File::Find;
use File::Spec;
use Cwd;

use Carp;
use Data::Dumper;
use SVN::Client;
# Our stuff
use SVN::S4::CatOrMods;
use SVN::S4::Config;
use SVN::S4::Debug qw (DEBUG is_debug);
use SVN::S4::Commit;
use SVN::S4::FixProp;
use SVN::S4::Getopt;
use SVN::S4::Info;
use SVN::S4::Path;
use SVN::S4::Scrub;
use SVN::S4::Snapshot;
use SVN::S4::Update;
use SVN::S4::ViewSpec;
use SVN::S4::WorkProp;
use strict;

######################################################################
#### Configuration Section

our $VERSION = '1.066';

# SVN::Client methods
#       $ctx->add($path, $recursive, $pool);
#       $ctx->blame($target, $start, $end, \&receiver, $pool);
#       $ctx->cat(\*FILEHANDLE, $target, $revision, $pool);
#       $ctx->checkout($url, $path, $revision, $recursive, $pool);
#       $ctx->cleanup($dir, $pool);
#       $ctx->commit($targets, $nonrecursive, $pool);
#       $ctx->copy($src_target, $src_revision, $dst_target, $pool);
#       $ctx->delete($targets, $force, $pool);
#       $ctx->diff($diff_options, $target1, $revision1, $target2, $revision2, $recursive,
#                 $ignore_ancestry, $no_diff_deleted, $outfile, $errfile, $pool);
#       $ctx->export($from, $to, $revision, $force, $pool);
#       $ctx->import($path, $url, $nonrecursive, $pool);
#       $ctx->log($targets, $start, $end, $discover_changed_paths, $strict_node_history,
#                 \&log_receiver, $pool);
#       $ctx->ls($target, $revision, $recursive, $pool);
#       $ctx->merge($src1, $rev1, $src2, $rev2, $target_wcpath, $recursive, $ignore_ancestry,
#                 $force, $dry_run, $pool);
#       $ctx->mkdir($targets, $pool);
#       $ctx->move($src_path, $src_revision, $dst_path, $force, $pool);
#       $ctx->propget($propname, $target, $revision, $recursive, $pool);
#       $ctx->proplist($target, $revision, $recursive, $pool);
#       $ctx->propset($propname, $propval, $target, $recursive, $pool);
#       $ctx->relocate($dir, $from, $to, $recursive, $pool);
#       $ctx->resolved($path, $recursive, $pool);
#       $ctx->revert($paths, $recursive, $pool);
#       $ctx->revprop_get($propname, $url, $revision, $pool);
#       $ctx->revprop_list($url, $revision, $pool);
#       $ctx->revprop_set($propname, $propval, $url, $revision, $force, $pool);
#       $ctx->status($path, $revision, \&status_func, $recursive, $get_all, $update, $no_ignore, $pool);
#       $ctx->switch($path, $url, $revision, $recursive, $pool);
#       $ctx->update($path, $revision, $recursive, $pool)
#       $ctx->url_from_path($target, $pool); or SVN::Client::url_from_path($target, $pool);
#       $ctx->uuid_from_path($path, $adm_access, $pool);
#       $ctx->uuid_from_url($url, $pool);

######################################################################
#### Constants
our %WCSTAT_STRINGS = (
    $SVN::Wc::Status::none => 'none',
    $SVN::Wc::Status::unversioned => 'unversioned',
    $SVN::Wc::Status::normal => 'normal',
    $SVN::Wc::Status::added => 'added',
    $SVN::Wc::Status::missing => 'missing',
    $SVN::Wc::Status::deleted => 'deleted',
    $SVN::Wc::Status::replaced => 'replaced',
    $SVN::Wc::Status::modified => 'modified',
    $SVN::Wc::Status::merged => 'merged',
    $SVN::Wc::Status::conflicted => 'conflicted',
    $SVN::Wc::Status::ignored => 'ignored',
    $SVN::Wc::Status::obstructed => 'obstructed',
    $SVN::Wc::Status::external => 'external',
    $SVN::Wc::Status::incomplete => 'incomplete',
);
our %WCSTAT_LETTERS = (
    $SVN::Wc::Status::none		=> ' ',
    $SVN::Wc::Status::unversioned	=> '?',
    $SVN::Wc::Status::normal		=> ' ',
    $SVN::Wc::Status::added		=> 'A',
    $SVN::Wc::Status::missing		=> '!',
    $SVN::Wc::Status::deleted		=> 'D',
    $SVN::Wc::Status::replaced		=> 'R',
    $SVN::Wc::Status::modified		=> 'M',
    $SVN::Wc::Status::merged		=> 'G',
    $SVN::Wc::Status::conflicted	=> 'C',
    $SVN::Wc::Status::ignored		=> 'I',
    $SVN::Wc::Status::obstructed	=> '!', #?
    $SVN::Wc::Status::external		=> 'X',
    $SVN::Wc::Status::incomplete 	=> '!', #?
);
our %WCKIND_STRINGS = (
    $SVN::Node::none => 'none',
    $SVN::Node::file => 'file',
    $SVN::Node::dir => 'dir',
    $SVN::Node::unknown => 'unknown',
);

######################################################################
#### Creators

sub new {
    my $class = shift;
    my $self = {# Overridable by user

lib/SVN/S4.pm  view on Meta::CPAN

    # example in regressions, and to test S4 itself (as the S4 program is under .svn and test_dir is not)
    if (defined $self->{_dir_uses_svn_cache}{$path}) {
    } elsif (-e "$path/.svn") {  # Short-circuit
	$self->{_dir_uses_svn_cache}{$path} = 1;
    } else {
	{
	    local $SVN::Error::handler = undef;
	    my $r = 0;
	    my $abspath = $self->abs_filename($path);  # Required for <= svn1.6
	    $self->client->status($abspath, undef, sub {
		my ($path,$wc_status2) = @_;
		#print "URL ",$wc_status->url(),"\n";
		if ($wc_status2->entry()) { $r=1; }
				  },
				  0, 1, 0, 0);
	    $self->{_dir_uses_svn_cache}{$path} = $r;
	}
    }
    return $self->{_dir_uses_svn_cache}{$path};
}

sub dir_uses_viewspec {
    my $self = shift;
    my $path = shift;

    my $abspath = $self->abs_filename($path);
    my $viewspec = "$abspath/$self->{viewspec_file}";

    # Ignore Viewspec's burried under other (possible) viewspecs
    my $parent_is_svn = $self->dir_uses_svn("$abspath/..");
    DEBUG "  Note this tree is under another svn tree ($abspath/../.svn)\n" if $parent_is_svn && $self->debug;
    return (!$parent_is_svn && -f $viewspec);
}

######################################################################
#### Properties

sub propget_string {
    my $self = shift;
    my %params = (#filename =>
		  #propname =>
		  dryrun => $self->{dryrun},
		  debug => $self->debug,
		  quiet => $self->{quiet},
		  @_);
    # Return property value for given file/propname
    my $filename = $self->clean_filename($params{filename});
    DEBUG "\tsvn_propget $filename  $params{propname}\n" if $self->debug;

    $self->open();
    $self->client_reopen();
    my $pl = $self->client->proplist($filename, undef, 0);
    return undef if !$pl;
    foreach my $propitem (@{$pl}) {
	my $propval = $propitem->prop_hash->{$params{propname}};
	return $propval if defined $propval;
    }
    return undef;
}

sub propset_string {
    my $self = shift;
    my %params = (#filename =>
		  #propname =>
		  #propval =>
		  dryrun => $self->{dryrun},
		  quiet => $self->{quiet},
		  @_);
    # Set property name, only if not set yet
    my $filename = $self->clean_filename($params{filename});

    $self->open();
    my $stored = $self->propget_string(%params);
    if (!defined $stored || (($stored ne $params{propval})
			     && "$stored\n" ne $params{propval})) {
	print "    svn propset $params{propname} $filename\n" if !$params{quiet};
	$self->client_reopen();
	$self->client->propset($params{propname}, $params{propval}, $params{filename}, 0) if !$params{dryrun};
    }
}

######################################################################
#### Package return
1;
=pod

=head1 NAME

SVN::S4 - Wrapper for Subversion

=head1 SYNOPSIS

  use SVN::S4;

=head1 DESCRIPTION

SVN::S4 is a derived class of SVN::Client.  The various SVN::S4::... classes
add member functions to this class to perform various functions.

=head1 METHODS

=over 4

=item $self->client

Return the SVN::Client object.

=item $self->propget_string(filename=>I<file>, propname=>I<prop>)

Return the string value of the property, or undef if not set or bad file.

=item $self->propset_string(filename=>I<file>, propname=>I<prop>, propval=>I<val>)

Set the string value of the property.

=item new (I<params>)

Create a new SVN::S4 object.

=back

=head1 DISTRIBUTION

The latest version is available from CPAN and from L<http://www.veripool.org/>.

Copyright 2002-2017 by Wilson Snyder.  This package is free software; you
can redistribute it and/or modify it under the terms of either the GNU
Lesser General Public License Version 3 or the Perl Artistic License Version 2.0.

=head1 AUTHORS

Bryce Denney <bryce.denney@sicortex.com> and
Wilson Snyder <wsnyder@wsnyder.org>

=head1 SEE ALSO

L<svn>, L<s4>

L<SVN::Client>,
L<SVN::S4::Commit>,
L<SVN::S4::FixProp>,
L<SVN::S4::Getopt>,
L<SVN::S4::Info>,
L<SVN::S4::Path>,
L<SVN::S4::Scrub>,
L<SVN::S4::Snapshot>,
L<SVN::S4::Update>,
L<SVN::S4::ViewSpec>

=cut
######################################################################



( run in 0.699 second using v1.01-cache-2.11-cpan-71847e10f99 )