@matheusbsbs / matheus-bagliano / commits / 6abd9332f9
Fork 0

git-svn: allow the mergeinfo property to be set

As a first step towards preserving merges across dcommit, we need a mechanism to update the svn:mergeinfo property. [ew: fixed bashism and style issues in test case] Signed-off-by: Steven Walter <stevenrwalter@gmail.com> Acked-by: Eric Wong <normalperson@yhbt.net>

Steven Walter committed Sep 24, 2010 at 23:51 UTC 6abd9332f97441a568421ba233ad8929b50a7efc
2 files changed +55 -1
git-svn.perl
+14 -1
@@ -84,7 +84,7 @@ my ($_stdin, $_help, $_edit,
84 $_version, $_fetch_all, $_no_rebase, $_fetch_parent,
85 $_merge, $_strategy, $_dry_run, $_local,
86 $_prefix, $_no_checkout, $_url, $_verbose,
87 - $_git_format, $_commit_url, $_tag);
87 + $_git_format, $_commit_url, $_tag, $_merge_info);
88 $Git::SVN::_follow_parent = 1;
89 $_q ||= 0;
90 my %remote_opts = ( 'username=s' => \$Git::SVN::Prompt::_username,
@@ -154,6 +154,7 @@ my %cmd = (
154 'commit-url=s' => \$_commit_url,
155 'revision|r=i' => \$_revision,
156 'no-rebase' => \$_no_rebase,
157 + 'mergeinfo=s' => \$_merge_info,
158 %cmt_opts, %fc_opts } ],
159 branch => [ \&cmd_branch,
160 'Create a branch in the SVN repository',
@@ -569,6 +570,7 @@ sub cmd_dcommit {
570 print "Committed r$_[0]\n";
571 $cmt_rev = $_[0];
572 },
573 + mergeinfo => $_merge_info,
574 svn_path => '');
575 if (!SVN::Git::Editor->new(\%ed_opts)->apply_diff) {
576 print "No changes\n$d~1 == $d\n";
@@ -4451,6 +4453,7 @@ sub new {
4453 $self->{path_prefix} = length $self->{svn_path} ?
4454 "$self->{svn_path}/" : '';
4455 $self->{config} = $opts->{config};
4456 + $self->{mergeinfo} = $opts->{mergeinfo};
4457 return $self;
4458 }
4459
@@ -4760,6 +4763,11 @@ sub change_file_prop {
4763 $self->SUPER::change_file_prop($fbat, $pname, $pval, $self->{pool});
4764 }
4765
4766 +sub change_dir_prop {
4767 + my ($self, $pbat, $pname, $pval) = @_;
4768 + $self->SUPER::change_dir_prop($pbat, $pname, $pval, $self->{pool});
4769 +}
4770 +
4771 sub _chg_file_get_blob ($$$$) {
4772 my ($self, $fbat, $m, $which) = @_;
4773 my $fh = $::_repository->temp_acquire("git_blob_$which");
@@ -4853,6 +4861,11 @@ sub apply_diff {
4861 fatal("Invalid change type: $f");
4862 }
4863 }
4864 +
4865 + if (defined($self->{mergeinfo})) {
4866 + $self->change_dir_prop($self->{bat}{''}, "svn:mergeinfo",
4867 + $self->{mergeinfo});
4868 + }
4869 $self->rmdirs if $_rmdir;
4870 if (@$mods == 0) {
4871 $self->abort_edit;
t/t9158-git-svn-mergeinfo.sh new
+41
@@ -0,0 +1,41 @@
1 +#!/bin/sh
2 +#
3 +# Copyright (c) 2010 Steven Walter
4 +#
5 +
6 +test_description='git svn mergeinfo propagation'
7 +
8 +. ./lib-git-svn.sh
9 +
10 +say 'define NO_SVN_TESTS to skip git svn tests'
11 +
12 +test_expect_success 'initialize source svn repo' '
13 + svn_cmd mkdir -m x "$svnrepo"/trunk &&
14 + svn_cmd co "$svnrepo"/trunk "$SVN_TREE" &&
15 + (
16 + cd "$SVN_TREE" &&
17 + touch foo &&
18 + svn_cmd add foo &&
19 + svn_cmd commit -m "initial commit"
20 + ) &&
21 + rm -rf "$SVN_TREE"
22 +'
23 +
24 +test_expect_success 'clone svn repo' '
25 + git svn init "$svnrepo"/trunk &&
26 + git svn fetch
27 +'
28 +
29 +test_expect_success 'change svn:mergeinfo' '
30 + touch bar &&
31 + git add bar &&
32 + git commit -m "bar" &&
33 + git svn dcommit --mergeinfo="/branches/foo:1-10"
34 +'
35 +
36 +test_expect_success 'verify svn:mergeinfo' '
37 + mergeinfo=$(svn_cmd propget svn:mergeinfo "$svnrepo"/trunk)
38 + test "$mergeinfo" = "/branches/foo:1-10"
39 +'
40 +
41 +test_done