X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=git-svn.perl;h=80b7b87f0f4f1933e551439ca4fb2cd68981a029;hb=d09e79cb1c474b3bb323356e6d1072922ab7ccb2;hp=54d23569337f680f7936390c8a83d2e7f2868c38;hpb=0a246571d47642dd7b6b796e601b820ca9f0c8c4;p=git.git diff --git a/git-svn.perl b/git-svn.perl index 54d235693..80b7b87f0 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -134,6 +134,7 @@ my %cmd = ( 'commit-diff' => [ \&commit_diff, 'Commit a diff between two trees', { 'message|m=s' => \$_message, 'file|F=s' => \$_file, + 'revision|r=s' => \$_revision, %cmt_opts } ], dcommit => [ \&dcommit, 'Commit several diffs to merge with upstream', { 'merge|m|M' => \$_merge, @@ -586,11 +587,21 @@ sub commit_lib { sub dcommit { my $gs = "refs/remotes/$GIT_SVN"; chomp(my @refs = safe_qx(qw/git-rev-list --no-merges/, "$gs..HEAD")); + my $last_rev; foreach my $d (reverse @refs) { + unless (defined $last_rev) { + (undef, $last_rev, undef) = cmt_metadata("$d~1"); + unless (defined $last_rev) { + die "Unable to extract revision information ", + "from commit $d~1\n"; + } + } if ($_dry_run) { print "diff-tree $d~1 $d\n"; } else { - commit_diff("$d~1", $d); + if (my $r = commit_diff("$d~1", $d, undef, $last_rev)) { + $last_rev = $r; + } # else: no changes, same $last_rev } } return if $_dry_run; @@ -814,6 +825,8 @@ sub commit_diff { print STDERR "Needed URL or usable git-svn id command-line\n"; commit_diff_usage(); } + my $r = shift || $_revision; + die "-r|--revision is a required argument\n" unless (defined $r); if (defined $_message && defined $_file) { print STDERR "Both --message/-m and --file/-F specified ", "for the commit message.\n", @@ -830,13 +843,22 @@ sub commit_diff { ($repo, $SVN_PATH) = repo_path_split($SVN_URL); $SVN_LOG ||= libsvn_connect($repo); $SVN ||= libsvn_connect($repo); + if ($r eq 'HEAD') { + $r = $SVN->get_latest_revnum; + } elsif ($r !~ /^\d+$/) { + die "revision argument: $r not understood by git-svn\n"; + } my @lock = $SVN::Core::VERSION ge '1.2.0' ? (undef, 0) : (); - my $ed = SVN::Git::Editor->new({ r => $SVN->get_latest_revnum, + my $rev_committed; + my $ed = SVN::Git::Editor->new({ r => $r, ra => $SVN_LOG, c => $tb, svn_path => $SVN_PATH }, $SVN->get_commit_editor($_message, - sub {print "Committed $_[0]\n"},@lock) + sub { + $rev_committed = $_[0]; + print "Committed $_[0]\n"; + }, @lock) ); my $mods = libsvn_checkout_tree($ta, $tb, $ed); if (@$mods == 0) { @@ -846,6 +868,7 @@ sub commit_diff { $ed->close_edit; } $_message = $_file = undef; + return $rev_committed; } ########################### utility functions ######################### @@ -1501,10 +1524,13 @@ sub svn_checkout_tree { apply_mod_line_blob($m); svn_check_prop_executable($m); } elsif ($m->{chg} eq 'T') { - sys(qw(svn rm --force),$m->{file_b}); - apply_mod_line_blob($m); - sys(qw(svn add), $m->{file_b}); svn_check_prop_executable($m); + apply_mod_line_blob($m); + if ($m->{mode_a} =~ /^120/ && $m->{mode_b} !~ /^120/) { + sys(qw(svn propdel svn:special), $m->{file_b}); + } else { + sys(qw(svn propset svn:special *),$m->{file_b}); + } } elsif ($m->{chg} eq 'A') { svn_ensure_parent_path( $m->{file_b} ); apply_mod_line_blob($m); @@ -2659,11 +2685,12 @@ sub libsvn_connect { } sub libsvn_get_file { - my ($gui, $f, $rev) = @_; + my ($gui, $f, $rev, $chg) = @_; my $p = $f; if (length $SVN_PATH > 0) { return unless ($p =~ s#^\Q$SVN_PATH\E/##); } + print "\t$chg\t$f\n" unless $_q; my ($hash, $pid, $in, $out); my $pool = SVN::Pool->new; @@ -2766,8 +2793,7 @@ sub libsvn_fetch { $pool->clear; } foreach (@amr) { - print "\t$_->[0]\t$_->[1]\n" unless $_q; - libsvn_get_file($gui, $_->[1], $rev) + libsvn_get_file($gui, $_->[1], $rev, $_->[0]); } close $gui or croak $?; return libsvn_log_entry($rev, $author, $date, $msg, [$last_commit]); @@ -2845,8 +2871,7 @@ sub libsvn_traverse { if (defined $files) { push @$files, $file; } else { - print "\tA\t$file\n" unless $_q; - libsvn_get_file($gui, $file, $rev); + libsvn_get_file($gui, $file, $rev, 'A'); } } } @@ -3137,7 +3162,7 @@ sub copy_remote_ref { my $ref = "refs/remotes/$GIT_SVN"; if (safe_qx('git-ls-remote', $origin, $ref)) { sys(qw/git fetch/, $origin, "$ref:$ref"); - } else { + } elsif ($_cp_remote && !$_upgrade) { die "Unable to find remote reference: ", "refs/remotes/$GIT_SVN on $origin\n"; }