X-Git-Url: https://git.octo.it/?p=git.git;a=blobdiff_plain;f=git-svnimport.perl;h=38ac732ca9b677a5647a96db44f7133b47db0648;hp=639aa41861a734aab225479be7524c972191da70;hb=HEAD;hpb=0cd5da56fa1287a368bb7e0d0e1379591d13f239 diff --git a/git-svnimport.perl b/git-svnimport.perl index 639aa418..38ac732c 100755 --- a/git-svnimport.perl +++ b/git-svnimport.perl @@ -63,10 +63,17 @@ my $svn_dir = $ARGV[1]; our @mergerx = (); if ($opt_m) { - @mergerx = ( qr/\W(?:from|of|merge|merging|merged) (\w+)/i ); + my $branch_esc = quotemeta ($branch_name); + my $trunk_esc = quotemeta ($trunk_name); + @mergerx = + ( + qr!\b(?:merg(?:ed?|ing))\b.*?\b((?:(?<=$branch_esc/)[\w\.\-]+)|(?:$trunk_esc))\b!i, + qr!\b(?:from|of)\W+((?:(?<=$branch_esc/)[\w\.\-]+)|(?:$trunk_esc))\b!i, + qr!\b(?:from|of)\W+(?:the )?([\w\.\-]+)[-\s]branch\b!i + ); } if ($opt_M) { - push (@mergerx, qr/$opt_M/); + unshift (@mergerx, qr/$opt_M/); } # Absolutize filename now, since we will have chdir'ed by the time we @@ -98,6 +105,7 @@ package SVNconn; use File::Spec; use File::Temp qw(tempfile); use POSIX qw(strftime dup2); +use Fcntl qw(SEEK_SET); sub new { my($what,$repo) = @_; @@ -135,17 +143,32 @@ sub file { print "... $rev $path ...\n" if $opt_v; my (undef, $properties); + my $pool = SVN::Pool->new(); eval { (undef, $properties) - = $self->{'svn'}->get_file($path,$rev,$fh); }; + = $self->{'svn'}->get_file($path,$rev,$fh,$pool); }; + $pool->clear; if($@) { return undef if $@ =~ /Attempted to get checksum/; die $@; } my $mode; if (exists $properties->{'svn:executable'}) { - $mode = '0755'; + $mode = '100755'; + } elsif (exists $properties->{'svn:special'}) { + my ($special_content, $filesize); + $filesize = tell $fh; + seek $fh, 0, SEEK_SET; + read $fh, $special_content, $filesize; + if ($special_content =~ s/^link //) { + $mode = '120000'; + seek $fh, 0, SEEK_SET; + truncate $fh, 0; + print $fh $special_content; + } else { + die "unexpected svn:special file encountered"; + } } else { - $mode = '0644'; + $mode = '100644'; } close ($fh); @@ -616,9 +639,7 @@ sub commit { } if(($action->[0] eq "A") || ($action->[0] eq "R")) { my $node_kind = node_kind($branch,$path,$revision); - if($action->[1]) { - copy_path($revision,$branch,$path,$action->[1],$action->[2],$node_kind,\@new,\@parents); - } elsif ($node_kind eq $SVN::Node::file) { + if ($node_kind eq $SVN::Node::file) { my $f = get_file($revision,$branch,$path); if ($f) { push(@new,$f) if $f; @@ -627,8 +648,15 @@ sub commit { print STDERR "$revision: $branch: could not fetch '$opath'\n"; } } elsif ($node_kind eq $SVN::Node::dir) { - get_ignore(\@new, \@old, $revision, - $branch,$path); + if($action->[1]) { + copy_path($revision, $branch, + $path, $action->[1], + $action->[2], $node_kind, + \@new, \@parents); + } else { + get_ignore(\@new, \@old, $revision, + $branch, $path); + } } } elsif ($action->[0] eq "D") { push(@old,$path); @@ -851,7 +879,7 @@ sub commit_all { $opt_l = $svn->{'maxrev'} if not defined $opt_l or $opt_l > $svn->{'maxrev'}; -if ($svn->{'maxrev'} < $current_rev) { +if ($opt_l < $current_rev) { print "Up to date: no new revisions to fetch!\n" if $opt_v; unlink("$git_dir/SVN2GIT_HEAD"); exit;