threads / patch / 25217

patchgit-svn: allow the mergeinfo property to be set

Subject: [PATCH] git-svn: allow the mergeinfo property to be set

## tl;dr

7 messages between Sep 24, 2010 and Oct 4, 2010. Diffs are folded; open one to read it.

replies: 6people: 4as markdown or json

Steven Walter· Sep 24, 2010, 00:52 UTC · lore
As a first step towards preserving merges across dcommit, we need a
mechanism to update the svn:mergeinfo property.
---
 git-svn.perl |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)
Show changes to git-svn.perl +14 −1
diff --git a/git-svn.perl b/git-svn.perl
index c7c4dcd..1612fd7 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -83,7 +83,7 @@ my ($_stdin, $_help, $_edit,
 	$_version, $_fetch_all, $_no_rebase, $_fetch_parent,
 	$_merge, $_strategy, $_dry_run, $_local,
 	$_prefix, $_no_checkout, $_url, $_verbose,
-	$_git_format, $_commit_url, $_tag);
+	$_git_format, $_commit_url, $_tag, $_merge_info);
 $Git::SVN::_follow_parent = 1;
 $_q ||= 0;
 my %remote_opts = ( 'username=s' => \$Git::SVN::Prompt::_username,
@@ -153,6 +153,7 @@ my %cmd = (
 			  'commit-url=s' => \$_commit_url,
 			  'revision|r=i' => \$_revision,
 			  'no-rebase' => \$_no_rebase,
+			  'mergeinfo=s' => \$_merge_info,
 			%cmt_opts, %fc_opts } ],
 	branch => [ \&cmd_branch,
 	            'Create a branch in the SVN repository',
@@ -568,6 +569,7 @@ sub cmd_dcommit {
 			                       print "Committed r$_[0]\n";
 			                       $cmt_rev = $_[0];
 			                },
+					mergeinfo => $_merge_info,
 			                svn_path => '');
 			if (!SVN::Git::Editor->new(\%ed_opts)->apply_diff) {
 				print "No changes\n$d~1 == $d\n";
@@ -4449,6 +4451,7 @@ sub new {
 	$self->{path_prefix} = length $self->{svn_path} ?
 	                       "$self->{svn_path}/" : '';
 	$self->{config} = $opts->{config};
+	$self->{mergeinfo} = $opts->{mergeinfo};
 	return $self;
 }
 
@@ -4758,6 +4761,11 @@ sub change_file_prop {
 	$self->SUPER::change_file_prop($fbat, $pname, $pval, $self->{pool});
 }
 
+sub change_dir_prop {
+	my ($self, $pbat, $pname, $pval) = @_;
+	$self->SUPER::change_dir_prop($pbat, $pname, $pval, $self->{pool});
+}
+
 sub _chg_file_get_blob ($$$$) {
 	my ($self, $fbat, $m, $which) = @_;
 	my $fh = $::_repository->temp_acquire("git_blob_$which");
@@ -4851,6 +4859,11 @@ sub apply_diff {
 			fatal("Invalid change type: $f");
 		}
 	}
+
+	if (defined($self->{mergeinfo})) {
+		$self->change_dir_prop($self->{bat}{''}, "svn:mergeinfo",
+			               $self->{mergeinfo});
+	}
 	$self->rmdirs if $_rmdir;
 	if (@$mods == 0) {
 		$self->abort_edit;
-- 
1.7.3.4.g4d78d
Eric Wong· Sep 24, 2010, 16:27 UTC · re: Steven Walter · lore

Re: [PATCH] git-svn: allow the mergeinfo property to be set

Steven Walter <stevenrwalter@gmail.com> wrote:
> As a first step towards preserving merges across dcommit, we need a
> mechanism to update the svn:mergeinfo property.
> ---
Hi Steven, this looks reasonable.  Sign-off?  A test would be nice, too.
-- 
Eric Wong
Steven Walter· Sep 25, 2010, 03:51 UTC · re: Eric Wong · lore

As a first step towards preserving merges across dcommit, we need a mechanism to update the svn:mergeinfo property.

Signed-off-by: Steven Walter <stevenrwalter@gmail.com>
---
 git-svn.perl                 |   15 ++++++++++++++-
 t/t9157-git-svn-mergeinfo.sh |   39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 1 deletions(-)
 create mode 100644 t/t9157-git-svn-mergeinfo.sh
Show changes to 2 files +53 −1

git-svn.perl, t/t9157-git-svn-mergeinfo.sh

diff --git a/git-svn.perl b/git-svn.perl
index c7c4dcd..1612fd7 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -83,7 +83,7 @@ my ($_stdin, $_help, $_edit,
 	$_version, $_fetch_all, $_no_rebase, $_fetch_parent,
 	$_merge, $_strategy, $_dry_run, $_local,
 	$_prefix, $_no_checkout, $_url, $_verbose,
-	$_git_format, $_commit_url, $_tag);
+	$_git_format, $_commit_url, $_tag, $_merge_info);
 $Git::SVN::_follow_parent = 1;
 $_q ||= 0;
 my %remote_opts = ( 'username=s' => \$Git::SVN::Prompt::_username,
@@ -153,6 +153,7 @@ my %cmd = (
 			  'commit-url=s' => \$_commit_url,
 			  'revision|r=i' => \$_revision,
 			  'no-rebase' => \$_no_rebase,
+			  'mergeinfo=s' => \$_merge_info,
 			%cmt_opts, %fc_opts } ],
 	branch => [ \&cmd_branch,
 	            'Create a branch in the SVN repository',
@@ -568,6 +569,7 @@ sub cmd_dcommit {
 			                       print "Committed r$_[0]\n";
 			                       $cmt_rev = $_[0];
 			                },
+					mergeinfo => $_merge_info,
 			                svn_path => '');
 			if (!SVN::Git::Editor->new(\%ed_opts)->apply_diff) {
 				print "No changes\n$d~1 == $d\n";
@@ -4449,6 +4451,7 @@ sub new {
 	$self->{path_prefix} = length $self->{svn_path} ?
 	                       "$self->{svn_path}/" : '';
 	$self->{config} = $opts->{config};
+	$self->{mergeinfo} = $opts->{mergeinfo};
 	return $self;
 }
 
@@ -4758,6 +4761,11 @@ sub change_file_prop {
 	$self->SUPER::change_file_prop($fbat, $pname, $pval, $self->{pool});
 }
 
+sub change_dir_prop {
+	my ($self, $pbat, $pname, $pval) = @_;
+	$self->SUPER::change_dir_prop($pbat, $pname, $pval, $self->{pool});
+}
+
 sub _chg_file_get_blob ($$$$) {
 	my ($self, $fbat, $m, $which) = @_;
 	my $fh = $::_repository->temp_acquire("git_blob_$which");
@@ -4851,6 +4859,11 @@ sub apply_diff {
 			fatal("Invalid change type: $f");
 		}
 	}
+
+	if (defined($self->{mergeinfo})) {
+		$self->change_dir_prop($self->{bat}{''}, "svn:mergeinfo",
+			               $self->{mergeinfo});
+	}
 	$self->rmdirs if $_rmdir;
 	if (@$mods == 0) {
 		$self->abort_edit;
diff --git a/t/t9157-git-svn-mergeinfo.sh b/t/t9157-git-svn-mergeinfo.sh
new file mode 100644
index 0000000..8337e44
--- /dev/null
+++ b/t/t9157-git-svn-mergeinfo.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+#
+# Copyright (c) 2010 Steven Walter
+#
+
+test_description='git svn mergeinfo propagation'
+
+. ./lib-git-svn.sh
+
+say 'define NO_SVN_TESTS to skip git svn tests'
+
+test_expect_success \
+    'initialize source svn repo' '
+        svn_cmd mkdir -m x "$svnrepo"/trunk &&
+        svn_cmd co "$svnrepo"/trunk "$SVN_TREE" &&
+        cd "$SVN_TREE" &&
+        touch foo &&
+        svn_cmd add foo &&
+        svn_cmd commit -m "initial commit" &&
+        cd .. &&
+        rm -rf "$SVN_TREE"'
+
+test_expect_success \
+    'clone svn repo' '
+        git svn init "$svnrepo"/trunk &&
+        git svn fetch'
+
+test_expect_success \
+    'change svn:mergeinfo' '
+        touch bar &&
+        git add bar &&
+        git commit -m "bar" &&
+        git svn dcommit --mergeinfo="/branches/foo:1-10"'
+
+test_expect_success \
+    'verify svn:mergeinfo' '
+        [ `svn_cmd propget svn:mergeinfo "$svnrepo"/trunk` == "/branches/foo:1-10" ]'
+
+test_done
-- 
1.6.3.3
Eric Wong· Sep 25, 2010, 04:24 UTC · re: Steven Walter · lore

Re: [PATCH] git-svn: allow the mergeinfo property to be set

Steven Walter <stevenrwalter@gmail.com> wrote:
> As a first step towards preserving merges across dcommit, we need a
> mechanism to update the svn:mergeinfo property.
> 
> Signed-off-by: Steven Walter <stevenrwalter@gmail.com>
Thanks Steven,

I fixed a bashism and style issues in test case, but nonetheless acked and pushed it out to git://git.bogomips.org/git-svn along with a few others I had forgotten to tell Junio about while I was on vacation:

Eric Wong (1):
      Documentation/git-svn: discourage "noMetadata"
Mathias Lafeldt (1):
      git-svn: fix processing of decorated commit hashes
Steven Walter (2):
      git-svn: check_cherry_pick should exclude commits already in our history
      git-svn: allow the mergeinfo property to be set
-- 
Eric Wong
Mathias Lafeldt· Oct 4, 2010, 07:56 UTC · re: Eric Wong · lore

Re: [PATCH] git-svn: allow the mergeinfo property to be set

Eric Wong wrote:
Show 22 quoted lines
> Steven Walter <stevenrwalter@gmail.com> wrote:
>> As a first step towards preserving merges across dcommit, we need a
>> mechanism to update the svn:mergeinfo property.
>>
>> Signed-off-by: Steven Walter <stevenrwalter@gmail.com>
> 
> Thanks Steven,
> 
> I fixed a bashism and style issues in test case, but nonetheless acked
> and pushed it out to git://git.bogomips.org/git-svn along with a few
> others I had forgotten to tell Junio about while I was on vacation:
> 
> Eric Wong (1):
>       Documentation/git-svn: discourage "noMetadata"
> 
> Mathias Lafeldt (1):
>       git-svn: fix processing of decorated commit hashes
> 
> Steven Walter (2):
>       git-svn: check_cherry_pick should exclude commits already in our history
>       git-svn: allow the mergeinfo property to be set
> 

So, is Junio aware of those patches? Or is it better to resubmit my fix separately?

-Mathias
Junio C Hamano· Oct 4, 2010, 17:38 UTC · re: Mathias Lafeldt · lore

Re: [PATCH] git-svn: allow the mergeinfo property to be set

Mathias Lafeldt <misfire@debugon.org> writes:
Show 17 quoted lines
>> I fixed a bashism and style issues in test case, but nonetheless acked
>> and pushed it out to git://git.bogomips.org/git-svn along with a few
>> others I had forgotten to tell Junio about while I was on vacation:
>> 
>> Eric Wong (1):
>>       Documentation/git-svn: discourage "noMetadata"
>> 
>> Mathias Lafeldt (1):
>>       git-svn: fix processing of decorated commit hashes
>> 
>> Steven Walter (2):
>>       git-svn: check_cherry_pick should exclude commits already in our history
>>       git-svn: allow the mergeinfo property to be set
>> 
>
> So, is Junio aware of those patches? Or is it better to resubmit my fix
> separately?
Now I am ;-)  Thanks for reminding me.
I found these four near Eric's 'master':
  833fde5 git-svn: allow the mergeinfo property to be set
  8565a56 git-svn: fix processing of decorated commit hashes
  a3c7505 git-svn: check_cherry_pick should exclude commits already in our history
  c9be27f Documentation/git-svn: discourage "noMetadata"

They all (perhaps except the very tip one) look fixes not enhancements, so I'll merge it to 'maint', so it can appear in 'master' and also in 1.7.3.2 in due course.

If 833fde5 needs to be excluded from 'maint', please advise.
Eric Wong· Oct 4, 2010, 22:05 UTC · re: Junio C Hamano · lore

Re: [PATCH] git-svn: allow the mergeinfo property to be set

Junio C Hamano <gitster@pobox.com> wrote:
Show 12 quoted lines
> I found these four near Eric's 'master':
> 
>   833fde5 git-svn: allow the mergeinfo property to be set
>   8565a56 git-svn: fix processing of decorated commit hashes
>   a3c7505 git-svn: check_cherry_pick should exclude commits already in our history
>   c9be27f Documentation/git-svn: discourage "noMetadata"
> 
> They all (perhaps except the very tip one) look fixes not enhancements, so
> I'll merge it to 'maint', so it can appear in 'master' and also in 1.7.3.2
> in due course.
> 
> If 833fde5 needs to be excluded from 'maint', please advise.
Yes, 833fde5 is an enhancement so it should be left out of 'maint'.

In the future, I suppose I could maintain my own 'maint' branch to make your life easier.

-- 
Eric Wong

← back to recent threads