Skip to contentSkip to conversation

Teach dcommit --mergeinfo to handle multiple lines

PATCH In review Bryan Jacobs 3 participants 7 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Teach dcommit --mergeinfo to handle multiple lines

"svn dcommit --mergeinfo" replaces the svn:mergeinfo property in an upstream SVN repository with the given text. The svn:mergeinfo property may contain commits originating on multiple branches, separated by newlines.

Cause space characters in the mergeinfo to be replaced by newlines, allowing a user to create history representing multiple branches being merged into one.

Update the corresponding documentation and add a test for the new functionality.

---
 Documentation/git-svn.txt    |    5 +++--
 git-svn.perl                 |    3 +++
 t/t9158-git-svn-mergeinfo.sh |   13 +++++++++++++
 3 files changed, 19 insertions(+), 2 deletions(-)
Documentation/git-svn.txt +3 -2
index ed5eca1..3ed28df 100644
@@ -211,8 +211,9 @@ discouraged.
 	Add the given merge information during the dcommit
 	(e.g. `--mergeinfo="/branches/foo:1-10"`). All svn server versions can
 	store this information (as a property), and svn clients starting from
-	version 1.5 can make use of it. 'git svn' currently does not use it
-	and does not set it automatically.
+	version 1.5 can make use of it. To specify merge information from multiple
+	branches, use a single space character between the branches
+	(`--mergeinfo="/branches/foo:1-10 /branches/bar:3,5-6,8"`)
 
 'branch'::
 	Create a branch in the SVN repository.
git-svn.perl +3 -0
index 89f83fd..3ee26a2 100755
@@ -548,6 +548,9 @@ sub cmd_dcommit {
 	}
 	my $expect_url = $url;
 	Git::SVN::remove_username($expect_url);
+	if (defined($_merge_info)) {
+		$_merge_info =~ tr{ }{\n};
+	}
 	while (1) {
 		my $d = shift @$linear_refs or last;
 		unless (defined $last_rev) {
t/t9158-git-svn-mergeinfo.sh +13 -0
index 3ab4390..8c9539e 100755
@@ -38,4 +38,17 @@ test_expect_success 'verify svn:mergeinfo' '
 	test "$mergeinfo" = "/branches/foo:1-10"
 '
 
+test_expect_success 'change svn:mergeinfo multiline' '
+	touch baz &&
+	git add baz &&
+	git commit -m "baz" &&
+	git svn dcommit --mergeinfo="/branches/bar:1-10 /branches/other:3-5,8,10-11"
+'
+
+test_expect_success 'verify svn:mergeinfo multiline' '
+	mergeinfo=$(svn_cmd propget svn:mergeinfo "$svnrepo"/trunk)
+	test "$mergeinfo" = "/branches/bar:1-10
+/branches/other:3-5,8,10-11"
+'
+
 test_done
Signature · 1 line
1.7.6
#1 lore raw

Subsystem commit subjects should be prefixed with the approriate subsystem (e.g. "git-svn: Teach dcommit --mergeinfo ..."

Quoted 5 lines · Bryan Jacobs

"svn dcommit --mergeinfo" replaces the svn:mergeinfo property in an upstream SVN repository with the given text. The svn:mergeinfo property may contain commits originating on multiple branches, separated by newlines.

Quoted 8 lines

Cause space characters in the mergeinfo to be replaced by newlines, allowing a user to create history representing multiple branches being merged into one.

Update the corresponding documentation and add a test for the new functionality.

This looks reasonable, Cc:-ing Sam since he handled the mergeinfo stuff. After all this time, I still have no experience using SVN mergeinfo anywhere :x

Quoted 60 lines
---
 Documentation/git-svn.txt    |    5 +++--
 git-svn.perl                 |    3 +++
 t/t9158-git-svn-mergeinfo.sh |   13 +++++++++++++
 3 files changed, 19 insertions(+), 2 deletions(-)
Documentation/git-svn.txt +3 -2
index ed5eca1..3ed28df 100644
@@ -211,8 +211,9 @@ discouraged.
 	Add the given merge information during the dcommit
 	(e.g. `--mergeinfo="/branches/foo:1-10"`). All svn server versions can
 	store this information (as a property), and svn clients starting from
-	version 1.5 can make use of it. 'git svn' currently does not use it
-	and does not set it automatically.
+	version 1.5 can make use of it. To specify merge information from multiple
+	branches, use a single space character between the branches
+	(`--mergeinfo="/branches/foo:1-10 /branches/bar:3,5-6,8"`)
 
 'branch'::
 	Create a branch in the SVN repository.
git-svn.perl +3 -0
index 89f83fd..3ee26a2 100755
@@ -548,6 +548,9 @@ sub cmd_dcommit {
 	}
 	my $expect_url = $url;
 	Git::SVN::remove_username($expect_url);
+	if (defined($_merge_info)) {
+		$_merge_info =~ tr{ }{\n};
+	}
 	while (1) {
 		my $d = shift @$linear_refs or last;
 		unless (defined $last_rev) {
t/t9158-git-svn-mergeinfo.sh +13 -0
index 3ab4390..8c9539e 100755
@@ -38,4 +38,17 @@ test_expect_success 'verify svn:mergeinfo' '
 	test "$mergeinfo" = "/branches/foo:1-10"
 '
 
+test_expect_success 'change svn:mergeinfo multiline' '
+	touch baz &&
+	git add baz &&
+	git commit -m "baz" &&
+	git svn dcommit --mergeinfo="/branches/bar:1-10 /branches/other:3-5,8,10-11"
+'
+
+test_expect_success 'verify svn:mergeinfo multiline' '
+	mergeinfo=$(svn_cmd propget svn:mergeinfo "$svnrepo"/trunk)
+	test "$mergeinfo" = "/branches/bar:1-10
+/branches/other:3-5,8,10-11"
+'
+
 test_done
Signature · 1 line
1.7.6
#2 lore raw
Quoted 11 lines · Eric Wong

Documentation/git-svn.txt discouraged. · line 216

Quoted 11 lines
Documentation/git-svn.txt +3 -2
@@ -211,8 +211,9 @@ discouraged.
  	Add the given merge information during the dcommit
  	(e.g. `--mergeinfo="/branches/foo:1-10"`). All svn server versions can
  	store this information (as a property), and svn clients starting from
-	version 1.5 can make use of it. 'git svn' currently does not use it
-	and does not set it automatically.
+	version 1.5 can make use of it. To specify merge information from multiple
+	branches, use a single space character between the branches
+	(`--mergeinfo="/branches/foo:1-10 /branches/bar:3,5-6,8"`)

This interface seems regrettably stupid. Like, do I need to consider the existing revisions that are already listed in the property? Is it really impossible to derive the changes that were merged and generate the list automatically?

But so long as it makes something previously impossible possible, it is a good change - my feeling is that it should be called something like --mergeinfo-raw or --mergeinfo-set to leave room for a possible --mergeinfo-add which knows how the lists work and adds them (which is what I'd expect a plain --mergeinfo switch to do).

Sam

#3 lore raw
Quoted 13 lines · On Wed, 31 Aug 2011 13:43:39 -0700 Sam Vilain <[email protected]> wrote:
Quoted 12 lines · Eric Wong
Quoted 12 lines
Documentation/git-svn.txt +0 -0
@@ -211,8 +211,9 @@ discouraged.
  	Add the given merge information during the dcommit
  	(e.g. `--mergeinfo="/branches/foo:1-10"`). All svn

server versions can store this information (as a property), and svn clients starting from

Documentation/git-svn.txt +0 -1
-	version 1.5 can make use of it. 'git svn' currently does

not use it

Documentation/git-svn.txt +1 -1
-	and does not set it automatically.
+	version 1.5 can make use of it. To specify merge

information from multiple

Quoted 8 lines
Quoted 3 lines

Documentation/git-svn.txt discouraged. · line 216

Quoted 3 lines
Documentation/git-svn.txt +1 -0
+	branches, use a single space character between the

branches

Documentation/git-svn.txt +1 -0
+	(`--mergeinfo="/branches/foo:1-10 /branches/bar:3,5-6,8"`)

This interface seems regrettably stupid. Like, do I need to consider the existing revisions that are already listed in the property? Is it really impossible to derive the changes that were merged and generate the list automatically?

Nope, it's possible. I didn't create the original --mergeinfo interface. I was very surprised when I first discovered it clobbered instead of integrating - it's easy to nuke your SVN repo's ability to merge with one careless use of this option. See below.

Quoted 5 lines

But so long as it makes something previously impossible possible, it is a good change - my feeling is that it should be called something like --mergeinfo-raw or --mergeinfo-set to leave room for a possible --mergeinfo-add which knows how the lists work and adds them (which is what I'd expect a plain --mergeinfo switch to do).

I completely agree. I think there should at least be a --mergeinfo-update which fetches the current revision, merges that with the provided set using the branch paths as keys (and compacts using svn:mergeinfo rules), and sets the property to the final result.

I actually do this currently with external scripts, which is why I wanted to make --mergeinfo capable of delivering my final payload. It would make my life easier if all the logic were part of git-svn instead.

That said, this change is really small. That change would be larger. So I submitted this first.

Quoted 1 line

Sam

#4 lore raw
Quoted 13 lines · Bryan Jacobs

...I didn't create the original --mergeinfo interface. I was very surprised when I first discovered it clobbered instead of integrating
- it's easy to nuke your SVN repo's ability to merge with one careless
use of this option. See below.

Quoted 5 lines

But so long as it makes something previously impossible possible, it is a good change - my feeling is that it should be called something like --mergeinfo-raw or --mergeinfo-set to leave room for a possible --mergeinfo-add which knows how the lists work and adds them (which is what I'd expect a plain --mergeinfo switch to do).

I completely agree. I think there should at least be a --mergeinfo-update which fetches the current revision, merges that with the provided set using the branch paths as keys (and compacts using svn:mergeinfo rules), and sets the property to the final result.

Quoted 7 lines

I actually do this currently with external scripts, which is why I wanted to make --mergeinfo capable of delivering my final payload. It would make my life easier if all the logic were part of git-svn instead.

That said, this change is really small. That change would be larger. So I submitted this first.

Ok, well I guess this is a useful intermediate feature then. Feel free to copy in any further changes you may come up with in this area to me, if you decide to do that.

Cheers,
Sam

#5 lore raw
Quoted 3 lines · Sam Vilain

Ok, well I guess this is a useful intermediate feature then. Feel free to copy in any further changes you may come up with in this area to me, if you decide to do that.

Shall I consider this an Acked-by?

Signature · 1 line
Eric Wong
Acked-by
#6 lore raw
Quoted 5 lines · Eric Wong
Quoted 3 lines · Sam Vilain

Ok, well I guess this is a useful intermediate feature then. Feel free to copy in any further changes you may come up with in this area to me, if you decide to do that.

Shall I consider this an Acked-by?

Cheers,
Sam