$_repack $_repack_flags/;
use Carp qw/croak/;
use File::Path qw/mkpath/;
+use File::Copy qw/copy/;
use IPC::Open3;
my $_repack_nr;
svn:entry:committed-date/;
}
+my %LOCKFILES;
+END { unlink keys %LOCKFILES if %LOCKFILES }
+
sub fetch_all {
my ($repo_id, $url, $fetch) = @_;
my @gs;
die "Failed to commit, invalid sha1: $commit\n";
}
- command_noisy('update-ref',$self->refname, $commit);
- $self->rev_db_set($log_entry->{revision}, $commit);
+ $self->rev_db_set($log_entry->{revision}, $commit, 1);
$self->{last_rev} = $log_entry->{revision};
$self->{last_commit} = $commit;
# to a revision: (41 * rev) is the byte offset.
# A record of 40 0s denotes an empty revision.
# And yes, it's still pretty fast (faster than Tie::File).
+# These files are disposable unless --no-metadata is set
sub rev_db_set {
- my ($self, $rev, $commit) = @_;
+ my ($self, $rev, $commit, $update_ref) = @_;
length $commit == 40 or croak "arg3 must be a full SHA1 hexsum\n";
- open my $fh, '+<', $self->{db_path} or croak $!;
+ my ($db, $db_lock) = ($self->{db_path}, "$self->{db_path}.lock");
+ my $sig;
+ if ($update_ref) {
+ $SIG{INT} = $SIG{HUP} = $SIG{TERM} = $SIG{ALRM} = $SIG{PIPE} =
+ $SIG{USR1} = $SIG{USR2} = sub { $sig = $_[0] };
+ }
+ $LOCKFILES{$db_lock} = 1;
+ if ($_no_metadata) {
+ copy($db, $db_lock) or die "rev_db_set(@_): ",
+ "Failed to copy: ",
+ "$db => $db_lock ($!)\n";
+ } else {
+ rename $db, $db_lock or die "rev_db_set(@_): ",
+ "Failed to rename: ",
+ "$db => $db_lock ($!)\n";
+ }
+ open my $fh, '+<', $db_lock or croak $!;
my $offset = $rev * 41;
# assume that append is the common case:
seek $fh, 0, 2 or croak $!;
seek $fh, $offset, 0 or croak $!;
print $fh $commit,"\n" or croak $!;
close $fh or croak $!;
+ if ($update_ref) {
+ command_noisy('update-ref', '-m', "r$rev",
+ $self->refname, $commit);
+ }
+ rename $db_lock, $db or die "rev_db_set(@_): ", "Failed to rename: ",
+ "$db_lock => $db ($!)\n";
+ delete $LOCKFILES{$db_lock};
+ if ($update_ref) {
+ $SIG{INT} = $SIG{HUP} = $SIG{TERM} = $SIG{ALRM} = $SIG{PIPE} =
+ $SIG{USR1} = $SIG{USR2} = 'DEFAULT';
+ kill $sig, $$ if defined $sig;
+ }
}
sub rev_db_get {