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>
This commit is contained in:
parent
f80b6de4ec
commit
6abd9332f9
15
git-svn.perl
15
git-svn.perl
@ -84,7 +84,7 @@ my ($_stdin, $_help, $_edit,
|
|||||||
$_version, $_fetch_all, $_no_rebase, $_fetch_parent,
|
$_version, $_fetch_all, $_no_rebase, $_fetch_parent,
|
||||||
$_merge, $_strategy, $_dry_run, $_local,
|
$_merge, $_strategy, $_dry_run, $_local,
|
||||||
$_prefix, $_no_checkout, $_url, $_verbose,
|
$_prefix, $_no_checkout, $_url, $_verbose,
|
||||||
$_git_format, $_commit_url, $_tag);
|
$_git_format, $_commit_url, $_tag, $_merge_info);
|
||||||
$Git::SVN::_follow_parent = 1;
|
$Git::SVN::_follow_parent = 1;
|
||||||
$_q ||= 0;
|
$_q ||= 0;
|
||||||
my %remote_opts = ( 'username=s' => \$Git::SVN::Prompt::_username,
|
my %remote_opts = ( 'username=s' => \$Git::SVN::Prompt::_username,
|
||||||
@ -154,6 +154,7 @@ my %cmd = (
|
|||||||
'commit-url=s' => \$_commit_url,
|
'commit-url=s' => \$_commit_url,
|
||||||
'revision|r=i' => \$_revision,
|
'revision|r=i' => \$_revision,
|
||||||
'no-rebase' => \$_no_rebase,
|
'no-rebase' => \$_no_rebase,
|
||||||
|
'mergeinfo=s' => \$_merge_info,
|
||||||
%cmt_opts, %fc_opts } ],
|
%cmt_opts, %fc_opts } ],
|
||||||
branch => [ \&cmd_branch,
|
branch => [ \&cmd_branch,
|
||||||
'Create a branch in the SVN repository',
|
'Create a branch in the SVN repository',
|
||||||
@ -569,6 +570,7 @@ sub cmd_dcommit {
|
|||||||
print "Committed r$_[0]\n";
|
print "Committed r$_[0]\n";
|
||||||
$cmt_rev = $_[0];
|
$cmt_rev = $_[0];
|
||||||
},
|
},
|
||||||
|
mergeinfo => $_merge_info,
|
||||||
svn_path => '');
|
svn_path => '');
|
||||||
if (!SVN::Git::Editor->new(\%ed_opts)->apply_diff) {
|
if (!SVN::Git::Editor->new(\%ed_opts)->apply_diff) {
|
||||||
print "No changes\n$d~1 == $d\n";
|
print "No changes\n$d~1 == $d\n";
|
||||||
@ -4451,6 +4453,7 @@ sub new {
|
|||||||
$self->{path_prefix} = length $self->{svn_path} ?
|
$self->{path_prefix} = length $self->{svn_path} ?
|
||||||
"$self->{svn_path}/" : '';
|
"$self->{svn_path}/" : '';
|
||||||
$self->{config} = $opts->{config};
|
$self->{config} = $opts->{config};
|
||||||
|
$self->{mergeinfo} = $opts->{mergeinfo};
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4760,6 +4763,11 @@ sub change_file_prop {
|
|||||||
$self->SUPER::change_file_prop($fbat, $pname, $pval, $self->{pool});
|
$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 ($$$$) {
|
sub _chg_file_get_blob ($$$$) {
|
||||||
my ($self, $fbat, $m, $which) = @_;
|
my ($self, $fbat, $m, $which) = @_;
|
||||||
my $fh = $::_repository->temp_acquire("git_blob_$which");
|
my $fh = $::_repository->temp_acquire("git_blob_$which");
|
||||||
@ -4853,6 +4861,11 @@ sub apply_diff {
|
|||||||
fatal("Invalid change type: $f");
|
fatal("Invalid change type: $f");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (defined($self->{mergeinfo})) {
|
||||||
|
$self->change_dir_prop($self->{bat}{''}, "svn:mergeinfo",
|
||||||
|
$self->{mergeinfo});
|
||||||
|
}
|
||||||
$self->rmdirs if $_rmdir;
|
$self->rmdirs if $_rmdir;
|
||||||
if (@$mods == 0) {
|
if (@$mods == 0) {
|
||||||
$self->abort_edit;
|
$self->abort_edit;
|
||||||
|
41
t/t9158-git-svn-mergeinfo.sh
Normal file
41
t/t9158-git-svn-mergeinfo.sh
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#!/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"
|
||||||
|
) &&
|
||||||
|
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' '
|
||||||
|
mergeinfo=$(svn_cmd propget svn:mergeinfo "$svnrepo"/trunk)
|
||||||
|
test "$mergeinfo" = "/branches/foo:1-10"
|
||||||
|
'
|
||||||
|
|
||||||
|
test_done
|
Loading…
Reference in New Issue
Block a user