SVK

 view release on metacpan or  search on metacpan

lib/SVK/XD.pm  view on Meta::CPAN

    my ($self, $target, %arg) = @_;

    $self->checkout_delta(
        $target->for_checkout_delta,
        %arg,
        xdroot => $target->create_xd_root,
        editor => SVK::Editor::Status->new(
            notify => SVK::Notify->new(
                cb_flush => sub {
                    my ($path, $status) = @_;
                    to_native($path, 'path');
                    my $copath = $target->copath($path);
                    my $report = $target->report ? $target->report->subdir($path) : $path;

                    $target->contains_copath ($copath) or return;
                    die loc ("%1 already added.\n", $report)
                        if !$arg{recursive} && ($status->[0] eq 'R' || $status->[0] eq 'A');

                    return unless $status->[0] eq 'D';
                    lstat ($copath);
                    $self->_do_add('R', $copath, $report, !-d _, %arg)
                        if -e _;
                },
            ),
        ),
        cb_unknown => sub {
            my ($editor, $path) = @_;
            to_native($path, 'path');
            my $copath = $target->copath($path);
            my $report = $target->_to_pclass($target->report)->subdir($path);
            lstat ($copath);
            $self->_do_add('A', $copath, $report, !-d _, %arg);
        },
	);
    return;
}

my %sch = (A => 'add', 'R' => 'replace');

sub _do_add {
    my ($self, $st, $copath, $report, $autoprop, %arg) = @_;
    my $newprop;
    $newprop = $self->auto_prop($copath) if $autoprop;

    $self->{checkout}->store($copath, {
            '.schedule' => $sch{$st},
            $autoprop ? ('.newprop' => $newprop) : ()
    });

    return if $arg{quiet};

    # determine whether the path is binary
    my $bin = q{};
    if ( ref $newprop && $newprop->{'svn:mime-type'} ) {
        $bin = ' - (bin)' if !mimetype_is_text( $newprop->{'svn:mime-type'} );
    }

    $logger->info( "$st   $report$bin");
}

sub do_propset {
    my ($self, $target, %arg) = @_;
    my ($entry, $schedule) = $self->get_entry($target->copath);
    $entry->{'.newprop'} ||= {};

    if ( $schedule ne 'add' && !$arg{'adjust_only'} ) {
        my $xdroot = $target->create_xd_root;
        my ( $source_path, $source_root )
            = $self->_copy_source( $entry, $target->copath, $xdroot );
        $source_path ||= $target->path_anchor;
        $source_root ||= $xdroot;
        die loc( "%1 is not under version control.\n", $target->report )
            if $xdroot->check_path($source_path) == $SVN::Node::none;
    }

    #XXX: support working on multiple paths and recursive
    die loc("%1 is already scheduled for delete.\n", $target->report)
	if $schedule eq 'delete' && !$arg{'adjust_only'};
    my %values;
    %values = %{$entry->{'.newprop'}} if exists $entry->{'.schedule'};
    my $pvalue = defined $arg{propvalue} ? $arg{propvalue} : \undef;

    if ( $arg{'adjust_only'} ) {
        return unless defined $values{ $arg{propname} };

        if ( defined $arg{propvalue} && $values{$arg{propname}} eq $pvalue ) {
            delete $values{ $arg{propname} };
        }
        elsif ( !defined $arg{propvalue} && (!defined $values{$arg{propname}} || (ref $values{$arg{propname}} && !defined $values{$arg{propname}}) )) {
            delete $values{ $arg{propname} };
        } else {
            $values{ $arg{propname} } = $pvalue;
        }
    } else {
        $values{ $arg{propname} } = $pvalue;
    }

    $self->{checkout}->store ($target->copath,
			      { '.schedule' => $schedule || 'prop',
				'.newprop' => \%values, });
    print " M  ".$target->report."\n" unless $arg{quiet};

    $self->fix_permission($target->copath, $arg{propvalue})
	if $arg{propname} eq 'svn:executable';
}

sub fix_permission {
    my ($self, $copath, $value) = @_;
    my $mode = (stat ($copath))[2];
    if (defined $value) {
	$mode |= 0111;
    }
    else {
	$mode &= ~0111;
    }
    chmod ($mode, $copath);
}

=item depot_delta

Generate C<SVN::Delta::Editor> calls to represent the changes between



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