SVN-Deploy
view release on metacpan or search on metacpan
lib/SVN/Deploy/Utils.pm view on Meta::CPAN
push(@dstack, $node);
} else {
my($svn_md5, $loc_md5);
my $state = 'new';
if ( defined($svnent) ) {
# exists in svn -> compare
my $svn_time = $svnent->time;
my $svn_size = $svnent->size;
$svn_md5
= _svn($ctx, 'propget', 'md5', $svnfile, 'HEAD', 0);
$svn_md5 = ($svn_md5 && $svn_md5->{$svnfile})
? $svn_md5->{$svnfile}
: '';
substr($svn_time, -6) = '';
my $loc_time = (stat($locfile))[9];
my $loc_size = -s $locfile;
$loc_md5 = _getmd5($locfile);
next if $loc_size == 0 and $svn_size == 0;
my $changed
= (
$loc_size != $svn_size
or $loc_time > $svn_time
or $loc_md5 ne $svn_md5
);
if ( $changed ) {
$state = 'changed';
} else {
next;
}
} else {
$loc_md5 = _getmd5($locfile);
}
_vlog " --> $state file: adding to svn";
# copying file to workdir
unless ( $to_commit{$subdir} and -d $to_commit{$subdir} ) {
my $tempsub = catdir($tempdir, join('-', @dstack) || 'root' );
_vlog " --> checkout '$url' to '$tempsub'";
_svn($ctx, 'checkout', $url, $tempsub, 'HEAD', 0)
or return;
$to_commit{$subdir} = $tempsub;
}
my $workfile = catfile($to_commit{$subdir}, $node);
copy($locfile, $workfile)
or croak "couldn't copy '$locfile' to '$workfile', $!";
chdir($to_commit{$subdir});
if ( $state eq 'new' ) {
_svn($ctx, 'add', $node, 0)
or return;
}
_svn($ctx, 'propset', 'md5', $loc_md5, $node, 0)
or return;
}
}} while @dstack or @{$todo{' '}};
for my $v ( values(%to_commit) ) {
my $info = _svn($ctx, 'commit', $v, 0)
or return;
$last_commit_revnum = $info->revision
if $info->revision != $SVN::Core::INVALID_REVNUM;
}
chdir($origdir);
return($last_commit_revnum);
}
1;
## POD
=head1 NAME
SVN::Deploy::Utils - utility functions for SVN::Deploy
=head1 SYNOPSIS
use SVN::Deploy::Utils;
my $rev = import_synch(
dir => '/my/local/dir',
url => 'svn://myrepo/trunk/mypath',
log => 'my import logmessage',
) or die $SVN::Deploy::Utils::LastErr;
=head1 DESCRIPTION
SVN::Deploy::Utils provides two high level utility functions
encapsuling SVN::Client methods.
=head1 FUNCTIONS
All functions return undef on error. $SVN::Deploy::Utils::LastErr will
contain a printable error message.
=head2 connect_cached
my $ctx = connect_cached(
[username => <name>,]
[password => <password>,]
[pwd_sub => <code_ref>,]
);
Returns an SVN::Client context object caching the authorization
information for later use. pwd_sub must reference a sub returning
username and password for e.g. user interaction.
=head2 import_synch
my $rev = import_synch(
( run in 0.769 second using v1.01-cache-2.11-cpan-71847e10f99 )