Skip to content

Commit 6abd933

Browse files
srwalterEric Wong
authored andcommitted
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>
1 parent f80b6de commit 6abd933

2 files changed

Lines changed: 55 additions & 1 deletion

File tree

git-svn.perl

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ BEGIN
8484
$_version, $_fetch_all, $_no_rebase, $_fetch_parent,
8585
$_merge, $_strategy, $_dry_run, $_local,
8686
$_prefix, $_no_checkout, $_url, $_verbose,
87-
$_git_format, $_commit_url, $_tag);
87+
$_git_format, $_commit_url, $_tag, $_merge_info);
8888
$Git::SVN::_follow_parent = 1;
8989
$_q ||= 0;
9090
my %remote_opts = ( 'username=s' => \$Git::SVN::Prompt::_username,
@@ -154,6 +154,7 @@ BEGIN
154154
'commit-url=s' => \$_commit_url,
155155
'revision|r=i' => \$_revision,
156156
'no-rebase' => \$_no_rebase,
157+
'mergeinfo=s' => \$_merge_info,
157158
%cmt_opts, %fc_opts } ],
158159
branch => [ \&cmd_branch,
159160
'Create a branch in the SVN repository',
@@ -569,6 +570,7 @@ sub cmd_dcommit {
569570
print "Committed r$_[0]\n";
570571
$cmt_rev = $_[0];
571572
},
573+
mergeinfo => $_merge_info,
572574
svn_path => '');
573575
if (!SVN::Git::Editor->new(\%ed_opts)->apply_diff) {
574576
print "No changes\n$d~1 == $d\n";
@@ -4451,6 +4453,7 @@ sub new {
44514453
$self->{path_prefix} = length $self->{svn_path} ?
44524454
"$self->{svn_path}/" : '';
44534455
$self->{config} = $opts->{config};
4456+
$self->{mergeinfo} = $opts->{mergeinfo};
44544457
return $self;
44554458
}
44564459

@@ -4760,6 +4763,11 @@ sub change_file_prop {
47604763
$self->SUPER::change_file_prop($fbat, $pname, $pval, $self->{pool});
47614764
}
47624765

4766+
sub change_dir_prop {
4767+
my ($self, $pbat, $pname, $pval) = @_;
4768+
$self->SUPER::change_dir_prop($pbat, $pname, $pval, $self->{pool});
4769+
}
4770+
47634771
sub _chg_file_get_blob ($$$$) {
47644772
my ($self, $fbat, $m, $which) = @_;
47654773
my $fh = $::_repository->temp_acquire("git_blob_$which");
@@ -4853,6 +4861,11 @@ sub apply_diff {
48534861
fatal("Invalid change type: $f");
48544862
}
48554863
}
4864+
4865+
if (defined($self->{mergeinfo})) {
4866+
$self->change_dir_prop($self->{bat}{''}, "svn:mergeinfo",
4867+
$self->{mergeinfo});
4868+
}
48564869
$self->rmdirs if $_rmdir;
48574870
if (@$mods == 0) {
48584871
$self->abort_edit;

t/t9158-git-svn-mergeinfo.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

0 commit comments

Comments
 (0)