@matheusbsbs / matheus-bagliano / commits / 0864e3ba12
Fork 0

git-svn: fix output reporting from the delta fetcher

There was nothing printed in the code originally because I left out a pair of parentheses. Nevertheless, the affected code has been replaced with a more efficient version that respects the -q flag as well as requiring less bandwidth. We save some bandwidth by not requesting changed paths information when calling get_log() since we're using the delta fetcher. Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <junkio@cox.net>

Eric Wong committed Nov 28, 2006 at 02:50 UTC 0864e3ba12ed946f0082297530584a77e2a7097b
1 file changed +15 -20
git-svn.perl
+15 -20
@@ -1152,7 +1152,7 @@ sub graft_file_copy_lib {
1152 while (1) {
1153 my $pool = SVN::Pool->new;
1154 libsvn_get_log(libsvn_dup_ra($SVN), [$path],
1155 - $min, $max, 0, 1, 1,
1155 + $min, $max, 0, 2, 1,
1156 sub {
1157 libsvn_graft_file_copies($grafts, $tree_paths,
1158 $path, @_);
@@ -2906,7 +2906,7 @@ sub libsvn_log_entry {
2906 }
2907
2908 sub process_rm {
2909 - my ($gui, $last_commit, $f) = @_;
2909 + my ($gui, $last_commit, $f, $q) = @_;
2910 # remove entire directories.
2911 if (safe_qx('git-ls-tree',$last_commit,'--',$f) =~ /^040000 tree/) {
2912 defined(my $pid = open my $ls, '-|') or croak $!;
@@ -2917,10 +2917,13 @@ sub process_rm {
2917 local $/ = "\0";
2918 while (<$ls>) {
2919 print $gui '0 ',0 x 40,"\t",$_ or croak $!;
2920 + print "\tD\t$_\n" unless $q;
2921 }
2922 + print "\tD\t$f/\n" unless $q;
2923 close $ls or croak $?;
2924 } else {
2925 print $gui '0 ',0 x 40,"\t",$f,"\0" or croak $!;
2926 + print "\tD\t$f\n" unless $q;
2927 }
2928 }
2929
@@ -2931,8 +2934,7 @@ sub libsvn_fetch {
2934 sub libsvn_fetch_delta {
2935 my ($last_commit, $paths, $rev, $author, $date, $msg) = @_;
2936 my $pool = SVN::Pool->new;
2934 - my $ed = SVN::Git::Fetcher->new({ c => $last_commit, ra => $SVN,
2935 - paths => $paths });
2937 + my $ed = SVN::Git::Fetcher->new({ c => $last_commit, q => $_q });
2938 my $reporter = $SVN->do_update($rev, '', 1, $ed, $pool);
2939 my @lock = $SVN::Core::VERSION ge '1.2.0' ? (undef) : ();
2940 my (undef, $last_rev, undef) = cmt_metadata($last_commit);
@@ -2959,8 +2961,7 @@ sub libsvn_fetch_full {
2961 $f =~ s#^/##;
2962 }
2963 if ($m =~ /^[DR]$/) {
2962 - print "\t$m\t$f\n" unless $_q;
2963 - process_rm($gui, $last_commit, $f);
2964 + process_rm($gui, $last_commit, $f, $_q);
2965 next if $m eq 'D';
2966 # 'R' can be file replacements, too, right?
2967 }
@@ -3101,7 +3102,7 @@ sub revisions_eq {
3102 # should be OK to use Pool here (r1 - r0) should be small
3103 my $pool = SVN::Pool->new;
3104 libsvn_get_log($SVN, [$path], $r0, $r1,
3104 - 0, 1, 1, sub {$nr++}, $pool);
3105 + 0, 0, 1, sub {$nr++}, $pool);
3106 $pool->clear;
3107 } else {
3108 my ($url, undef) = repo_path_split($SVN_URL);
@@ -3177,6 +3178,7 @@ sub libsvn_find_parent_branch {
3178
3179 sub libsvn_get_log {
3180 my ($ra, @args) = @_;
3181 + $args[4]-- if $args[4] && $_xfer_delta && ! $_follow_parent;
3182 if ($SVN::Core::VERSION le '1.2.0') {
3183 splice(@args, 3, 1);
3184 }
@@ -3190,7 +3192,7 @@ sub libsvn_new_tree {
3192 my ($paths, $rev, $author, $date, $msg) = @_;
3193 if ($_xfer_delta) {
3194 my $pool = SVN::Pool->new;
3193 - my $ed = SVN::Git::Fetcher->new({paths => $paths, ra => $SVN});
3195 + my $ed = SVN::Git::Fetcher->new({q => $_q});
3196 my $reporter = $SVN->do_update($rev, '', 1, $ed, $pool);
3197 my @lock = $SVN::Core::VERSION ge '1.2.0' ? (undef) : ();
3198 $reporter->set_path('', $rev, 1, @lock, $pool);
@@ -3388,20 +3390,14 @@ sub new {
3390 open my $gui, '| git-update-index -z --index-info' or croak $!;
3391 $self->{gui} = $gui;
3392 $self->{c} = $git_svn->{c} if exists $git_svn->{c};
3391 - if (my $p = $git_svn->{paths} && $git_svn->{ra}) {
3392 - my $s = $git_svn->{ra}->{svn_path};
3393 - $s = length $s ? qr#^/\Q$s\E/# : qr#^/#;
3394 - $self->{paths} = { map { my $x = $_;
3395 - $x =~ s/$s//;
3396 - $x => $p->{$_} } keys %$p };
3397 - }
3393 + $self->{q} = $git_svn->{q};
3394 require Digest::MD5;
3395 $self;
3396 }
3397
3398 sub delete_entry {
3399 my ($self, $path, $rev, $pb) = @_;
3404 - process_rm($self->{gui}, $self->{c}, $path);
3400 + process_rm($self->{gui}, $self->{c}, $path, $self->{q});
3401 undef;
3402 }
3403
@@ -3410,13 +3406,13 @@ sub open_file {
3406 my ($mode, $blob) = (safe_qx('git-ls-tree',$self->{c},'--',$path)
3407 =~ /^(\d{6}) blob ([a-f\d]{40})\t/);
3408 { path => $path, mode_a => $mode, mode_b => $mode, blob => $blob,
3413 - pool => SVN::Pool->new };
3409 + pool => SVN::Pool->new, action => 'M' };
3410 }
3411
3412 sub add_file {
3413 my ($self, $path, $pb, $cp_path, $cp_rev) = @_;
3414 { path => $path, mode_a => 100644, mode_b => 100644,
3419 - pool => SVN::Pool->new };
3415 + pool => SVN::Pool->new, action => 'A' };
3416 }
3417
3418 sub change_file_prop {
@@ -3499,8 +3495,7 @@ sub close_file {
3495 $fb->{pool}->clear;
3496 my $gui = $self->{gui};
3497 print $gui "$fb->{mode_b} $hash\t$path\0" or croak $!;
3502 - print "\t", $self->{paths}->{$path}->action,
3503 - "\t$path\n" if defined $self->{paths}->{$path};
3498 + print "\t$fb->{action}\t$path\n" if $fb->{action} && ! $self->{q};
3499 undef;
3500 }
3501