From: Andrew Wong <andrew.kw.w@gmail.com>
To: git@vger.kernel.org
Cc: Andrew Wong <andrew.kw.w@gmail.com>
Subject: [RFC 2/3] git-svn: Support cherry-pick merges
Date: Thu, 28 Nov 2013 10:52:16 -0500 [thread overview]
Message-ID: <1385653937-29595-3-git-send-email-andrew.kw.w@gmail.com> (raw)
In-Reply-To: <1385653937-29595-1-git-send-email-andrew.kw.w@gmail.com>
Detect a cherry-pick merge if there's only one parent and the git-svn-id
metadata exists. Then, get the parent's mergeinfo and merge this commit's
mergeinfo.
---
git-svn.perl | 52 +++++++++++++++++++++++++++++++++++++--
t/t9161-git-svn-mergeinfo-push.sh | 30 ++++++++++++++++++++++
2 files changed, 80 insertions(+), 2 deletions(-)
diff --git a/git-svn.perl b/git-svn.perl
index 9ddeaf4..b04cac7 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -698,12 +698,14 @@ sub populate_merge_info {
my %parentshash;
read_commit_parents(\%parentshash, $d);
my @parents = @{$parentshash{$d}};
+
+ my $rooturl = $gs->repos_root;
+ my ($target_branch) = $gs->full_pushurl =~ /^\Q$rooturl\E(.*)/;
+
if ($#parents > 0) {
# Merge commit
my $all_parents_ok = 1;
my $aggregate_mergeinfo = '';
- my $rooturl = $gs->repos_root;
- my ($target_branch) = $gs->full_pushurl =~ /^\Q$rooturl\E(.*)/;
if (defined($rewritten_parent)) {
# Replace first parent with newly-rewritten version
@@ -785,6 +787,52 @@ sub populate_merge_info {
if ($all_parents_ok and $aggregate_mergeinfo) {
return $aggregate_mergeinfo;
}
+ } elsif ($#parents == 0) {
+ # cherry-pick merge
+ my ($cherry_branchurl, $cherry_svnrev, $cherry_paruuid) =
+ cmt_metadata($d);
+
+ if(defined $cherry_branchurl && defined $cherry_svnrev && defined $cherry_paruuid)
+ {
+ if (defined($rewritten_parent)) {
+ # Replace first parent with newly-rewritten version
+ shift @parents;
+ unshift @parents, $rewritten_parent;
+ }
+
+ my $aggregate_mergeinfo = '';
+
+ # parent mergeinfo
+ my ($branchurl, $svnrev, $paruuid) =
+ cmt_metadata($parents[0]);
+
+ my $ra = Git::SVN::Ra->new($branchurl);
+ my (undef, undef, $props) =
+ $ra->get_dir(canonicalize_path("."), $svnrev);
+ my $parent_mergeinfo = $props->{'svn:mergeinfo'};
+ unless (defined $parent_mergeinfo) {
+ $parent_mergeinfo = '';
+ }
+
+ $aggregate_mergeinfo = merge_merge_info($aggregate_mergeinfo,
+ $parent_mergeinfo,
+ $target_branch);
+
+ # cherry-pick mergeinfo
+ unless ($cherry_branchurl =~ /^\Q$rooturl\E(.*)/) {
+ fatal "commit $d git-svn metadata changed mid-run!";
+ }
+ my $cherry_branchpath = $1;
+
+ my $cherry_pick_mergeinfo = canonicalize_path("$cherry_branchpath")
+ . ":$cherry_svnrev";
+
+ $aggregate_mergeinfo = merge_merge_info($aggregate_mergeinfo,
+ $cherry_pick_mergeinfo,
+ $target_branch);
+
+ return $aggregate_mergeinfo;
+ }
}
return undef;
diff --git a/t/t9161-git-svn-mergeinfo-push.sh b/t/t9161-git-svn-mergeinfo-push.sh
index 1eab701..f348392 100755
--- a/t/t9161-git-svn-mergeinfo-push.sh
+++ b/t/t9161-git-svn-mergeinfo-push.sh
@@ -91,6 +91,36 @@ test_expect_success 'check reintegration mergeinfo' '
/branches/svnb5:6,11"
'
+test_expect_success 'make further commits to branch' '
+ git checkout svnb2 &&
+ touch newb2file-3 &&
+ git add newb2file-3 &&
+ git commit -m "later b2 commit 3" &&
+ touch newb2file-4 &&
+ git add newb2file-4 &&
+ git commit -m "later b2 commit 4" &&
+ touch newb2file-5 &&
+ git add newb2file-5 &&
+ git commit -m "later b2 commit 5" &&
+ git svn dcommit
+ '
+
+test_expect_success 'cherry-pick merge' '
+ git checkout svnb1 &&
+ git cherry-pick svnb2 &&
+ git cherry-pick svnb2^ &&
+ git cherry-pick svnb2^^ &&
+ git svn dcommit
+ '
+
+test_expect_success 'check cherry-pick mergeinfo' '
+ mergeinfo=$(svn_cmd propget svn:mergeinfo "$svnrepo"/branches/svnb1)
+ test "$mergeinfo" = "/branches/svnb2:3,8,16-17,20-22
+/branches/svnb3:4,9
+/branches/svnb4:5-6,10-12
+/branches/svnb5:6,11"
+ '
+
test_expect_success 'dcommit a merge at the top of a stack' '
git checkout svnb1 &&
touch anotherfile &&
--
1.8.5.rc3.5.g96ccada
next prev parent reply other threads:[~2013-11-28 15:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-28 15:52 [RFC 0/3] git-svn: Add support for cherry-pick merges Andrew Wong
2013-11-28 15:52 ` [RFC 1/3] git-svn: Generate mergeinfo for every commit Andrew Wong
2013-11-28 15:52 ` Andrew Wong [this message]
2013-11-28 15:52 ` [RFC 3/3] git-svn: Add config to control the path of mergeinfo Andrew Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1385653937-29595-3-git-send-email-andrew.kw.w@gmail.com \
--to=andrew.kw.w@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).