git-svn: reintroduce using a single get_log() to fetch
We'll need to rely on path matching to handle wildcard support for branches and tags. Signed-off-by: Eric Wong <normalperson@yhbt.net>
This commit is contained in:
parent
4bb9ed0466
commit
fbcc1737d6
103
git-svn.perl
103
git-svn.perl
@ -1112,6 +1112,24 @@ sub do_git_commit {
|
|||||||
return $commit;
|
return $commit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub match_paths {
|
||||||
|
my ($self, $paths, $r) = @_;
|
||||||
|
$self->{path_regex} ||= qr/^\/\Q$self->{path}\E\/?/;
|
||||||
|
if (grep /$self->{path_regex}/, keys %$paths) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
my $c = '';
|
||||||
|
foreach (split m#/#, $self->{path}) {
|
||||||
|
$c .= "/$_";
|
||||||
|
next unless ($paths->{$c} && ($paths->{$c}->{action} eq 'A'));
|
||||||
|
my @x = eval { $self->ra->get_dir($self->{path}, $r) };
|
||||||
|
if (scalar @x == 3) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
sub find_parent_branch {
|
sub find_parent_branch {
|
||||||
my ($self, $paths, $rev) = @_;
|
my ($self, $paths, $rev) = @_;
|
||||||
return undef unless $_follow_parent;
|
return undef unless $_follow_parent;
|
||||||
@ -1308,15 +1326,21 @@ sub make_log_entry {
|
|||||||
print $un $_, "\n" foreach @$untracked;
|
print $un $_, "\n" foreach @$untracked;
|
||||||
my %log_entry = ( parents => $parents || [], revision => $rev,
|
my %log_entry = ( parents => $parents || [], revision => $rev,
|
||||||
log => '');
|
log => '');
|
||||||
my $rp = $self->ra->rev_proplist($rev);
|
|
||||||
foreach (sort keys %$rp) {
|
my $logged = delete $self->{logged_rev_props};
|
||||||
my $v = $rp->{$_};
|
if (!$logged || $self->{-want_extra_revprops}) {
|
||||||
if (/^svn:(author|date|log)$/) {
|
my $rp = $self->ra->rev_proplist($rev);
|
||||||
$log_entry{$1} = $v;
|
foreach (sort keys %$rp) {
|
||||||
} else {
|
my $v = $rp->{$_};
|
||||||
print $un " rev_prop: ", uri_encode($_), ' ',
|
if (/^svn:(author|date|log)$/) {
|
||||||
uri_encode($v), "\n";
|
$log_entry{$1} = $v;
|
||||||
|
} else {
|
||||||
|
print $un " rev_prop: ", uri_encode($_), ' ',
|
||||||
|
uri_encode($v), "\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
map { $log_entry{$_} = $logged->{$_} } keys %$logged;
|
||||||
}
|
}
|
||||||
close $un or croak $!;
|
close $un or croak $!;
|
||||||
|
|
||||||
@ -2416,55 +2440,26 @@ sub gs_fetch_loop_common {
|
|||||||
}
|
}
|
||||||
while (1) {
|
while (1) {
|
||||||
my %revs;
|
my %revs;
|
||||||
my $err;
|
|
||||||
my $err_handler = $SVN::Error::handler;
|
my $err_handler = $SVN::Error::handler;
|
||||||
$SVN::Error::handler = sub {
|
$SVN::Error::handler = \&skip_unknown_revs;
|
||||||
($err) = @_;
|
$self->get_log([''], $min, $max, 0, 1, 1, sub {
|
||||||
skip_unknown_revs($err);
|
my ($paths, $r, $author, $date, $log) = @_;
|
||||||
};
|
$revs{$r} = [ dup_changed_paths($paths),
|
||||||
foreach my $gs (@gs) {
|
{ author => $author,
|
||||||
my $min_r = $min;
|
date => $date,
|
||||||
my $rdb_max = $gs->rev_db_max;
|
log => $log } ] });
|
||||||
next if $rdb_max >= $max;
|
|
||||||
$min_r = $rdb_max + 1 if ($rdb_max > $min_r);
|
|
||||||
$self->get_log([$gs->{path}], $min_r, $max,
|
|
||||||
0, 1, 1, sub
|
|
||||||
{ my ($paths, $rev) = @_;
|
|
||||||
push @{$revs{$rev}},
|
|
||||||
[ $gs,
|
|
||||||
dup_changed_paths($paths) ] });
|
|
||||||
|
|
||||||
next unless ($err && $max >= $head);
|
|
||||||
|
|
||||||
print STDERR "Path '$gs->{path}' ",
|
|
||||||
"was probably deleted:\n",
|
|
||||||
$err->expanded_message,
|
|
||||||
"\nWill attempt to follow ",
|
|
||||||
"revisions r$min .. r$max ",
|
|
||||||
"committed before the deletion\n";
|
|
||||||
my $hi = $max;
|
|
||||||
while (--$hi >= $min) {
|
|
||||||
my $ok;
|
|
||||||
$self->get_log([$gs->{path}], $min, $hi,
|
|
||||||
0, 1, 1, sub {
|
|
||||||
my ($paths, $rev) = @_;
|
|
||||||
$ok = $rev;
|
|
||||||
push @{$revs{$rev}}, [ $gs,
|
|
||||||
dup_changed_paths($_[0])]});
|
|
||||||
if ($ok) {
|
|
||||||
print STDERR "r$min .. r$ok OK\n";
|
|
||||||
last;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$SVN::Error::handler = $err_handler;
|
$SVN::Error::handler = $err_handler;
|
||||||
|
|
||||||
foreach my $r (sort {$a <=> $b} keys %revs) {
|
foreach my $r (sort {$a <=> $b} keys %revs) {
|
||||||
foreach (@{$revs{$r}}) {
|
my ($paths, $logged) = @{$revs{$r}};
|
||||||
my ($gs, $paths) = @$_;
|
foreach my $gs (@gs) {
|
||||||
my $lr = $gs->last_rev;
|
if ($gs->rev_db_max >= $r) {
|
||||||
next if defined $lr && $lr >= $r;
|
next;
|
||||||
next if defined $gs->rev_db_get($r);
|
}
|
||||||
if (my $log_entry = $gs->do_fetch($paths, $r)) {
|
next unless $gs->match_paths($paths, $r);
|
||||||
|
$gs->{logged_rev_props} = $logged;
|
||||||
|
my $log_entry = $gs->do_fetch($paths, $r);
|
||||||
|
if ($log_entry) {
|
||||||
$gs->do_git_commit($log_entry);
|
$gs->do_git_commit($log_entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user