{"thread":{"id":"2325","subject":"[PATCH 5/7] When copying files and/or directories from several branches in one single","startedAt":"2005-11-02T21:51:57Z","lastAt":"2005-11-02T21:51:57Z","messageCount":1,"participants":["Yaacov Akiba Slama"],"isPatch":true,"patchVersion":1,"patchTotal":7},"messages":[{"id":"11040","messageId":"E1EXQWT-00050K-VB@localhost.localdomain","threadId":"2325","inReplyTo":null,"subject":"[PATCH 5/7] When copying files and/or directories from several branches in one single","fromName":"Yaacov Akiba Slama","fromEmail":"ya@slamail.org","sentAt":"2005-11-02T21:51:57Z","receivedAt":"2005-11-02T21:51:57Z","isPatch":true,"sender":{"key":"ya@slamail.org","avatar":null},"body":"revision, all these branches are used as parents of the commit.\n\nSigned-off-by: Yaacov Akiba Slama <ya@slamail.org>\n\n---\n\n git-svnimport.perl |   22 ++++++++++++++++------\n 1 files changed, 16 insertions(+), 6 deletions(-)\n\napplies-to: 71ff99dad666ebbb05cb14744df010bf223678c6\n7554fc8ad3df5f08a269b4ef0a05acdbc33f2302\ndiff --git a/git-svnimport.perl b/git-svnimport.perl\nindex 9cee629..ae82a7c 100755\n--- a/git-svnimport.perl\n+++ b/git-svnimport.perl\n@@ -365,12 +365,12 @@ sub branch_rev($$) {\n \treturn $therev;\n }\n \n-sub copy_path($$$$$$$) {\n+sub copy_path($$$$$$$$) {\n \t# Somebody copied a whole subdirectory.\n \t# We need to find the index entries from the old version which the\n \t# SVN log entry points to, and add them to the new place.\n \n-\tmy($newrev,$newbranch,$path,$oldpath,$rev,$node_kind,$new) = @_;\n+\tmy($newrev,$newbranch,$path,$oldpath,$rev,$node_kind,$new,$parents) = @_;\n \n \tmy($srcbranch,$srcpath) = split_path($rev,$oldpath);\n \tmy $therev = branch_rev($srcbranch, $rev);\n@@ -379,6 +379,9 @@ sub copy_path($$$$$$$) {\n \t\tprint STDERR \"$newrev:$newbranch: could not find $oldpath \\@ $rev\\n\";\n \t\treturn;\n \t}\n+\tif ($srcbranch ne $newbranch) {\n+\t\tpush(@$parents, $branches{$srcbranch}{'LAST'});\n+\t}\n \tprint \"$newrev:$newbranch:$path: copying from $srcbranch:$srcpath @ $rev\\n\" if $opt_v;\n \tif ($node_kind eq $SVN::Node::dir) {\n \t\t\t$srcpath =~ s#/*$#/#;\n@@ -405,7 +408,7 @@ sub copy_path($$$$$$$) {\n sub commit {\n \tmy($branch, $changed_paths, $revision, $author, $date, $message) = @_;\n \tmy($author_name,$author_email,$dest);\n-\tmy(@old,@new);\n+\tmy(@old,@new,@parents);\n \n \tif (not defined $author) {\n \t\t$author_name = $author_email = \"unknown\";\n@@ -492,6 +495,8 @@ sub commit {\n \t\t$last_rev = $rev;\n \t}\n \n+\tpush (@parents, $rev) if defined $rev;\n+\n \tmy $cid;\n \tif($tag and not %$changed_paths) {\n \t\t$cid = $rev;\n@@ -507,7 +512,7 @@ sub commit {\n \t\t\tif(($action->[0] eq \"A\") || ($action->[0] eq \"R\")) {\n \t\t\t\tmy $node_kind = node_kind($branch,$path,$revision);\n \t\t\t\tif($action->[1]) {\n-\t\t\t\t\tcopy_path($revision,$branch,$path,$action->[1],$action->[2],$node_kind,\\@new);\n+\t\t\t\t\tcopy_path($revision,$branch,$path,$action->[1],$action->[2],$node_kind,\\@new,\\@parents);\n \t\t\t\t} elsif ($node_kind eq $SVN::Node::file) {\n \t\t\t\t\tmy $f = get_file($revision,$branch,$path);\n \t\t\t\t\tif ($f) {\n@@ -592,7 +597,6 @@ sub commit {\n \t\t\t$pw->close();\n \n \t\t\tmy @par = ();\n-\t\t\t@par = (\"-p\",$rev) if defined $rev;\n \n \t\t\t# loose detection of merges\n \t\t\t# based on the commit msg\n@@ -602,11 +606,17 @@ sub commit {\n \t\t\t\t\tif ($mparent eq 'HEAD') { $mparent = $opt_o };\n \t\t\t\t\tif ( -e \"$git_dir/refs/heads/$mparent\") {\n \t\t\t\t\t\t$mparent = get_headref($mparent, $git_dir);\n-\t\t\t\t\t\tpush @par, '-p', $mparent;\n+\t\t\t\t\t\tpush (@parents, $mparent);\n \t\t\t\t\t\tprint OUT \"Merge parent branch: $mparent\\n\" if $opt_v;\n \t\t\t\t\t}\n \t\t\t\t}\n \t\t\t}\n+\t\t\tmy %seen_parents = ();\n+\t\t\tmy @unique_parents = grep { ! $seen_parents{$_} ++ } @parents;\n+\t\t\tforeach my $bparent (@unique_parents) {\n+\t\t\t\tpush @par, '-p', $bparent;\n+\t\t\t\tprint OUT \"Merge parent branch: $bparent\\n\" if $opt_v;\n+\t\t\t}\n \n \t\t\texec(\"env\",\n \t\t\t\t\"GIT_AUTHOR_NAME=$author_name\",\n---\n0.99.9.GIT\n"}]}