Bundle file copies from multiple branches into a merge.
When copying files and/or directories from several branches in one single revision, all these branches are used as parents of the commit. Signed-off-by: Yaacov Akiba Slama <ya@slamail.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Yaacov Akiba Slama committed
Nov 2, 2005 at 23:51 UTC
109fc2b97b73090a4a0a6550cdf9b2446fd12389
1 file changed
+16
-6
git-svnimport.perl
+16
-6
@@ -365,12 +365,12 @@ sub branch_rev($$) {
365
return $therev;
366
}
367
368
-sub copy_path($$$$$$$) {
368
+sub copy_path($$$$$$$$) {
369
# Somebody copied a whole subdirectory.
370
# We need to find the index entries from the old version which the
371
# SVN log entry points to, and add them to the new place.
372
373
- my($newrev,$newbranch,$path,$oldpath,$rev,$node_kind,$new) = @_;
373
+ my($newrev,$newbranch,$path,$oldpath,$rev,$node_kind,$new,$parents) = @_;
374
375
my($srcbranch,$srcpath) = split_path($rev,$oldpath);
376
my $therev = branch_rev($srcbranch, $rev);
@@ -379,6 +379,9 @@ sub copy_path($$$$$$$) {
379
print STDERR "$newrev:$newbranch: could not find $oldpath \@ $rev\n";
380
return;
381
}
382
+ if ($srcbranch ne $newbranch) {
383
+ push(@$parents, $branches{$srcbranch}{'LAST'});
384
+ }
385
print "$newrev:$newbranch:$path: copying from $srcbranch:$srcpath @ $rev\n" if $opt_v;
386
if ($node_kind eq $SVN::Node::dir) {
387
$srcpath =~ s#/*$#/#;
@@ -405,7 +408,7 @@ sub copy_path($$$$$$$) {
408
sub commit {
409
my($branch, $changed_paths, $revision, $author, $date, $message) = @_;
410
my($author_name,$author_email,$dest);
408
- my(@old,@new);
411
+ my(@old,@new,@parents);
412
413
if (not defined $author) {
414
$author_name = $author_email = "unknown";
@@ -492,6 +495,8 @@ sub commit {
495
$last_rev = $rev;
496
}
497
498
+ push (@parents, $rev) if defined $rev;
499
+
500
my $cid;
501
if($tag and not %$changed_paths) {
502
$cid = $rev;
@@ -507,7 +512,7 @@ sub commit {
512
if(($action->[0] eq "A") || ($action->[0] eq "R")) {
513
my $node_kind = node_kind($branch,$path,$revision);
514
if($action->[1]) {
510
- copy_path($revision,$branch,$path,$action->[1],$action->[2],$node_kind,\@new);
515
+ copy_path($revision,$branch,$path,$action->[1],$action->[2],$node_kind,\@new,\@parents);
516
} elsif ($node_kind eq $SVN::Node::file) {
517
my $f = get_file($revision,$branch,$path);
518
if ($f) {
@@ -592,7 +597,6 @@ sub commit {
597
$pw->close();
598
599
my @par = ();
595
- @par = ("-p",$rev) if defined $rev;
600
601
# loose detection of merges
602
# based on the commit msg
@@ -602,11 +606,17 @@ sub commit {
606
if ($mparent eq 'HEAD') { $mparent = $opt_o };
607
if ( -e "$git_dir/refs/heads/$mparent") {
608
$mparent = get_headref($mparent, $git_dir);
605
- push @par, '-p', $mparent;
609
+ push (@parents, $mparent);
610
print OUT "Merge parent branch: $mparent\n" if $opt_v;
611
}
612
}
613
}
614
+ my %seen_parents = ();
615
+ my @unique_parents = grep { ! $seen_parents{$_} ++ } @parents;
616
+ foreach my $bparent (@unique_parents) {
617
+ push @par, '-p', $bparent;
618
+ print OUT "Merge parent branch: $bparent\n" if $opt_v;
619
+ }
620
621
exec("env",
622
"GIT_AUTHOR_NAME=$author_name",