git-svn: use private $GIT_DIR/svn/config file more
Switch max_rev storage over to using it for globbing branches and tags. Signed-off-by: Eric Wong <normalperson@yhbt.net>
This commit is contained in:
53
git-svn.perl
53
git-svn.perl
@ -738,16 +738,10 @@ sub fetch_all {
|
|||||||
foreach my $t (qw/branches tags/) {
|
foreach my $t (qw/branches tags/) {
|
||||||
defined $remote->{$t} or next;
|
defined $remote->{$t} or next;
|
||||||
push @globs, $remote->{$t};
|
push @globs, $remote->{$t};
|
||||||
my $f = "$ENV{GIT_DIR}/svn/.$uuid.$t";
|
my $max_rev = eval { tmp_config(qw/--int --get/,
|
||||||
if (open my $fh, '<', $f) {
|
"svn-remote.$repo_id.${t}-maxRev") };
|
||||||
chomp(my $max_rev = <$fh>);
|
if (defined $max_rev && ($max_rev < $base)) {
|
||||||
close $fh or die "Error closing $f: $!\n";
|
$base = $max_rev;
|
||||||
|
|
||||||
if ($max_rev !~ /^\d+$/) {
|
|
||||||
die "$max_rev (in $f) is not an integer!\n";
|
|
||||||
}
|
|
||||||
$remote->{$t}->{max_rev} = $max_rev;
|
|
||||||
$base = $max_rev if ($max_rev < $base);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -774,6 +768,7 @@ sub read_all_remotes {
|
|||||||
my ($p, $g) = ($3, $4);
|
my ($p, $g) = ($3, $4);
|
||||||
my $rs = $r->{$1}->{$2} = {
|
my $rs = $r->{$1}->{$2} = {
|
||||||
t => $2,
|
t => $2,
|
||||||
|
remote => $1,
|
||||||
path => Git::SVN::GlobSpec->new($p),
|
path => Git::SVN::GlobSpec->new($p),
|
||||||
ref => Git::SVN::GlobSpec->new($g) };
|
ref => Git::SVN::GlobSpec->new($g) };
|
||||||
if (length($rs->{ref}->{right}) != 0) {
|
if (length($rs->{ref}->{right}) != 0) {
|
||||||
@ -951,8 +946,8 @@ sub set_svm_vars {
|
|||||||
# see if we have it in our config, first:
|
# see if we have it in our config, first:
|
||||||
eval {
|
eval {
|
||||||
$self->{svm} = {
|
$self->{svm} = {
|
||||||
source => $self->tmp_config('--get', "$section.svm-source"),
|
source => tmp_config('--get', "$section.svm-source"),
|
||||||
uuid => $self->tmp_config('--get', "$section.svm-uuid"),
|
uuid => tmp_config('--get', "$section.svm-uuid"),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return $ra if ($self->{svm}->{source} && $self->{svm}->{uuid});
|
return $ra if ($self->{svm}->{source} && $self->{svm}->{uuid});
|
||||||
@ -968,12 +963,12 @@ sub set_svm_vars {
|
|||||||
# username is of no interest
|
# username is of no interest
|
||||||
$src =~ s{!$}{};
|
$src =~ s{!$}{};
|
||||||
$src =~ s{(^[a-z\+]*://)[^/@]*@}{$1};
|
$src =~ s{(^[a-z\+]*://)[^/@]*@}{$1};
|
||||||
$self->tmp_config('--add', "$section.svm-source", $src);
|
tmp_config('--add', "$section.svm-source", $src);
|
||||||
|
|
||||||
my $uuid = $props->{'svm:uuid'};
|
my $uuid = $props->{'svm:uuid'};
|
||||||
$uuid =~ m{^[0-9a-f\-]{30,}$}
|
$uuid =~ m{^[0-9a-f\-]{30,}$}
|
||||||
or die "doesn't look right - svm:uuid is '$uuid'\n";
|
or die "doesn't look right - svm:uuid is '$uuid'\n";
|
||||||
$self->tmp_config('--add', "$section.svm-uuid", $uuid);
|
tmp_config('--add', "$section.svm-uuid", $uuid);
|
||||||
|
|
||||||
$self->{svm} = { source => $src , uuid => $uuid };
|
$self->{svm} = { source => $src , uuid => $uuid };
|
||||||
}
|
}
|
||||||
@ -1079,18 +1074,19 @@ sub get_fetch_range {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub tmp_config {
|
sub tmp_config {
|
||||||
my ($self, @args) = @_;
|
my (@args) = @_;
|
||||||
unless (-f $self->{config}) {
|
my $config = "$ENV{GIT_DIR}/svn/config";
|
||||||
open my $fh, '>', $self->{config} or
|
unless (-f $config) {
|
||||||
die "Can't open $self->{config}: $!\n";
|
open my $fh, '>', $config or
|
||||||
|
die "Can't open $config: $!\n";
|
||||||
print $fh "; This file is used internally by git-svn\n" or
|
print $fh "; This file is used internally by git-svn\n" or
|
||||||
die "Couldn't write to $self->{config}: $!\n";
|
die "Couldn't write to $config: $!\n";
|
||||||
print $fh "; You should not have to edit it\n" or
|
print $fh "; You should not have to edit it\n" or
|
||||||
die "Couldn't write to $self->{config}: $!\n";
|
die "Couldn't write to $config: $!\n";
|
||||||
close $fh or die "Couldn't close $self->{config}: $!\n";
|
close $fh or die "Couldn't close $config: $!\n";
|
||||||
}
|
}
|
||||||
my $old_config = $ENV{GIT_CONFIG};
|
my $old_config = $ENV{GIT_CONFIG};
|
||||||
$ENV{GIT_CONFIG} = $self->{config};
|
$ENV{GIT_CONFIG} = $config;
|
||||||
$@ = undef;
|
$@ = undef;
|
||||||
my @ret = eval { command('config', @args) };
|
my @ret = eval { command('config', @args) };
|
||||||
my $err = $@;
|
my $err = $@;
|
||||||
@ -2673,16 +2669,9 @@ sub gs_fetch_loop_common {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach my $g (@$globs) {
|
foreach my $g (@$globs) {
|
||||||
my $f = "$ENV{GIT_DIR}/svn/." .
|
my $k = "svn-remote.$g->{remote}." .
|
||||||
$self->uuid . ".$g->{t}";
|
"$g->{t}-maxRev";
|
||||||
open my $fh, '>', "$f.tmp" or
|
Git::SVN::tmp_config($k, $r);
|
||||||
die "Can't open $f.tmp for writing: $!";
|
|
||||||
print $fh "$r\n" or
|
|
||||||
die "Couldn't write to $f: $!\n";
|
|
||||||
close $fh or die "Error closing $f: $!\n";
|
|
||||||
rename "$f.tmp", $f or
|
|
||||||
die "Couldn't rename ",
|
|
||||||
"$f.tmp => $f: $!\n";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# pre-fill the .rev_db since it'll eventually get filled in
|
# pre-fill the .rev_db since it'll eventually get filled in
|
||||||
|
Reference in New Issue
Block a user