public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Michael Contreras <michael@inetric•com>
To: git@vger•kernel.org
Cc: Bryan Jacobs <bjacobs@woti•com>,
	Eric Wong <normalperson@yhbt•net>,
	Avishay Lavie <avishay.lavie@gmail•com>,
	Sam Vilain <sam.vilain@catalyst•net.nz>
Subject: [PATCH] git-svn: avoid self-referencing mergeinfo
Date: Sat, 30 Mar 2013 18:06:42 -0400	[thread overview]
Message-ID: <20130330220642.GA14641@gmail.com> (raw)

When svn.pushmergeinfo is set, the target branch is included in the
mergeinfo if it was previously merged into one of the source branches.
SVN does not do this.

Remove merge target branch path from resulting mergeinfo when
svn.pushmergeinfo is set to better match the behavior of SVN. Update the
svn-mergeinfo-push test.

Signed-off-by: Michael Contreras <michael@inetric•com>
Reported-by: Avishay Lavie <avishay.lavie@gmail•com>
---

Avishay's original patch was never applied.
http://thread.gmane.org/gmane.comp.version-control.git/193123

 git-svn.perl                      | 9 ++++++---
 t/t9161-git-svn-mergeinfo-push.sh | 1 -
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index b46795f..bd4388d 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -669,12 +669,14 @@ sub merge_revs_into_hash {
 }
 
 sub merge_merge_info {
-	my ($mergeinfo_one, $mergeinfo_two) = @_;
+	my ($mergeinfo_one, $mergeinfo_two, $ignore_branch) = @_;
 	my %result_hash = ();
 
 	merge_revs_into_hash(\%result_hash, $mergeinfo_one);
 	merge_revs_into_hash(\%result_hash, $mergeinfo_two);
 
+	delete $result_hash{$ignore_branch} if $ignore_branch;
+
 	my $result = '';
 	# Sort below is for consistency's sake
 	for my $branchname (sort keys(%result_hash)) {
@@ -695,6 +697,7 @@ sub populate_merge_info {
 		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
@@ -726,7 +729,7 @@ sub populate_merge_info {
 			# Merge previous mergeinfo values
 			$aggregate_mergeinfo =
 				merge_merge_info($aggregate_mergeinfo,
-								 $par_mergeinfo, 0);
+								 $par_mergeinfo, $target_branch);
 
 			next if $parent eq $parents[0]; # Skip first parent
 			# Add new changes being placed in tree by merge
@@ -769,7 +772,7 @@ sub populate_merge_info {
 			my $newmergeinfo = "$branchpath:" . join(',', @revsin);
 			$aggregate_mergeinfo =
 				merge_merge_info($aggregate_mergeinfo,
-								 $newmergeinfo, 1);
+								 $newmergeinfo, $target_branch);
 		}
 		if ($all_parents_ok and $aggregate_mergeinfo) {
 			return $aggregate_mergeinfo;
diff --git a/t/t9161-git-svn-mergeinfo-push.sh b/t/t9161-git-svn-mergeinfo-push.sh
index 6ef0c0b..1eab701 100755
--- a/t/t9161-git-svn-mergeinfo-push.sh
+++ b/t/t9161-git-svn-mergeinfo-push.sh
@@ -88,7 +88,6 @@ test_expect_success 'check reintegration mergeinfo' '
 	test "$mergeinfo" = "/branches/svnb1:2-4,7-9,13-18
 /branches/svnb2:3,8,16-17
 /branches/svnb3:4,9
-/branches/svnb4:5-6,10-12
 /branches/svnb5:6,11"
 	'
 
-- 
1.8.2

             reply	other threads:[~2013-03-30 22:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-30 22:06 Michael Contreras [this message]
2013-04-04  1:31 ` [PATCH] git-svn: avoid self-referencing mergeinfo Eric 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=20130330220642.GA14641@gmail.com \
    --to=michael@inetric$(echo .)com \
    --cc=avishay.lavie@gmail$(echo .)com \
    --cc=bjacobs@woti$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=normalperson@yhbt$(echo .)net \
    --cc=sam.vilain@catalyst$(echo .)net.nz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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