From a51cdb0c0420ee3bef26bbd1a9aa75e1d464e5b7 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 7 Sep 2007 04:00:40 -0700 Subject: git-svn: fix "Malformed network data" with svn:// servers We have a workaround for the reparent function not working correctly on the SVN native protocol servers. This workaround opens a new connection (SVN::Ra object) to the new URL/directory. Since libsvn appears limited to only supporting one connection at a time, this workaround invalidates the Git::SVN::Ra object that is $self inside gs_fetch_loop_common(). So we need to restart that connection once all the fetching is done for each loop iteration to be able to run get_log() successfully. Signed-off-by: Eric Wong Signed-off-by: Junio C Hamano --- git-svn.perl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index d3c8cd0b8e..fbd4691bc5 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -3013,7 +3013,7 @@ package Git::SVN::Ra; use vars qw/@ISA $config_dir $_log_window_size/; use strict; use warnings; -my ($can_do_switch, %ignored_err, $RA); +my ($ra_invalid, $can_do_switch, %ignored_err, $RA); BEGIN { # enforce temporary pool usage for some simple functions @@ -3174,7 +3174,11 @@ sub gs_do_switch { $self->{url} = $full_url; $reparented = 1; } else { + $_[0] = undef; + $self = undef; + $RA = undef; $ra = Git::SVN::Ra->new($full_url); + $ra_invalid = 1; } } $ra ||= $self; @@ -3234,6 +3238,7 @@ sub gs_fetch_loop_common { my $inc = $_log_window_size; my ($min, $max) = ($base, $head < $base + $inc ? $head : $base + $inc); my $longest_path = longest_common_path($gsv, $globs); + my $ra_url = $self->{url}; while (1) { my %revs; my $err; @@ -3295,6 +3300,13 @@ sub gs_fetch_loop_common { "$g->{t}-maxRev"; Git::SVN::tmp_config($k, $r); } + if ($ra_invalid) { + $_[0] = undef; + $self = undef; + $RA = undef; + $self = Git::SVN::Ra->new($ra_url); + $ra_invalid = undef; + } } # pre-fill the .rev_db since it'll eventually get filled in # with '0' x40 if something new gets committed -- cgit v1.2.1 From 7b02b85a66fee6b357e02f9e70dd0baa0fd24308 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 8 Sep 2007 16:33:08 -0700 Subject: git-svn: understand grafts when doing dcommit Use the rev-list --parents functionality to read the parents of the commit. cat-file only shows the raw object with the original parents and doesn't take into account grafts; so we'll rely on rev-list machinery for the smarts here. Signed-off-by: Eric Wong Signed-off-by: Junio C Hamano --- git-svn.perl | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index fbd4691bc5..f8181609f9 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -841,14 +841,9 @@ sub working_head_info { sub read_commit_parents { my ($parents, $c) = @_; - my ($fh, $ctx) = command_output_pipe(qw/cat-file commit/, $c); - while (<$fh>) { - chomp; - last if ''; - /^parent ($sha1)/ or next; - push @{$parents->{$c}}, $1; - } - close $fh; # break the pipe + chomp(my $p = command_oneline(qw/rev-list --parents -1/, $c)); + $p =~ s/^($c)\s*// or die "rev-list --parents -1 $c failed!\n"; + @{$parents->{$c}} = split(/ /, $p); } sub linearize_history { -- cgit v1.2.1