From: Andrew Wong <andrew.kw.w@gmail.com>
To: git@vger.kernel.org
Cc: Andrew Wong <andrew.kw.w@gmail.com>
Subject: [RFC 3/3] git-svn: Add config to control the path of mergeinfo
Date: Thu, 28 Nov 2013 10:52:17 -0500 [thread overview]
Message-ID: <1385653937-29595-4-git-send-email-andrew.kw.w@gmail.com> (raw)
In-Reply-To: <1385653937-29595-1-git-send-email-andrew.kw.w@gmail.com>
Instead of always storing mergeinfo at the root, give an option to store the
merge info in a subdirectory. The subdirectory must exist before we try to set
its property.
---
git-svn.perl | 21 +++++++++++++++------
perl/Git/SVN/Editor.pm | 5 ++++-
t/t9161-git-svn-mergeinfo-push.sh | 37 +++++++++++++++++++++++++++++++++++++
3 files changed, 56 insertions(+), 7 deletions(-)
diff --git a/git-svn.perl b/git-svn.perl
index b04cac7..bfae579 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -693,7 +693,7 @@ sub merge_merge_info {
}
sub populate_merge_info {
- my ($d, $gs, $uuid, $linear_refs, $rewritten_parent) = @_;
+ my ($d, $gs, $uuid, $linear_refs, $rewritten_parent, $merge_info_path) = @_;
my %parentshash;
read_commit_parents(\%parentshash, $d);
@@ -729,7 +729,7 @@ sub populate_merge_info {
my $ra = Git::SVN::Ra->new($branchurl);
my (undef, undef, $props) =
- $ra->get_dir(canonicalize_path("."), $svnrev);
+ $ra->get_dir(canonicalize_path($merge_info_path), $svnrev);
my $par_mergeinfo = $props->{'svn:mergeinfo'};
unless (defined $par_mergeinfo) {
$par_mergeinfo = '';
@@ -778,7 +778,8 @@ sub populate_merge_info {
# We now have a list of all SVN revnos which are
# merged by this particular parent. Integrate them.
next if $#revsin == -1;
- my $newmergeinfo = "$branchpath:" . join(',', @revsin);
+ my $newmergeinfo = canonicalize_path("$branchpath/$merge_info_path")
+ . ":" . join(',', @revsin);
$aggregate_mergeinfo =
merge_merge_info($aggregate_mergeinfo,
$newmergeinfo,
@@ -808,7 +809,7 @@ sub populate_merge_info {
my $ra = Git::SVN::Ra->new($branchurl);
my (undef, undef, $props) =
- $ra->get_dir(canonicalize_path("."), $svnrev);
+ $ra->get_dir(canonicalize_path($merge_info_path), $svnrev);
my $parent_mergeinfo = $props->{'svn:mergeinfo'};
unless (defined $parent_mergeinfo) {
$parent_mergeinfo = '';
@@ -824,7 +825,7 @@ sub populate_merge_info {
}
my $cherry_branchpath = $1;
- my $cherry_pick_mergeinfo = canonicalize_path("$cherry_branchpath")
+ my $cherry_pick_mergeinfo = canonicalize_path("$cherry_branchpath/$merge_info_path")
. ":$cherry_svnrev";
$aggregate_mergeinfo = merge_merge_info($aggregate_mergeinfo,
@@ -1008,6 +1009,12 @@ sub cmd_dcommit {
if (defined($_merge_info)) {
$_merge_info =~ tr{ }{\n};
}
+ my $merge_info_path = eval {
+ command_oneline(qw/config --get svn.mergeinfopath/)
+ };
+ if (not defined($merge_info_path)) {
+ $merge_info_path = "";
+ }
while (1) {
my $d = shift @$linear_refs or last;
unless (defined $last_rev) {
@@ -1030,7 +1037,8 @@ sub cmd_dcommit {
$rev_merge_info = populate_merge_info($d, $gs,
$uuid,
$linear_refs,
- $rewritten_parent);
+ $rewritten_parent,
+ $merge_info_path);
}
my %ed_opts = ( r => $last_rev,
@@ -1046,6 +1054,7 @@ sub cmd_dcommit {
$cmt_rev = $_[0];
},
mergeinfo => $rev_merge_info,
+ mergeinfopath => $merge_info_path,
svn_path => '');
my $err_handler = $SVN::Error::handler;
diff --git a/perl/Git/SVN/Editor.pm b/perl/Git/SVN/Editor.pm
index b3bcd47..dcbb8a0 100644
--- a/perl/Git/SVN/Editor.pm
+++ b/perl/Git/SVN/Editor.pm
@@ -42,6 +42,7 @@ sub new {
"$self->{svn_path}/" : '';
$self->{config} = $opts->{config};
$self->{mergeinfo} = $opts->{mergeinfo};
+ $self->{mergeinfopath} = $opts->{mergeinfopath};
return $self;
}
@@ -484,7 +485,9 @@ sub apply_diff {
}
if (defined($self->{mergeinfo})) {
- $self->change_dir_prop($self->{bat}{''}, "svn:mergeinfo",
+ my $pbat = $self->ensure_path($self->{mergeinfopath}, \%deletions);
+ $self->change_dir_prop($pbat,
+ "svn:mergeinfo",
$self->{mergeinfo});
}
$self->rmdirs if $_rmdir;
diff --git a/t/t9161-git-svn-mergeinfo-push.sh b/t/t9161-git-svn-mergeinfo-push.sh
index f348392..8a87ad7 100755
--- a/t/t9161-git-svn-mergeinfo-push.sh
+++ b/t/t9161-git-svn-mergeinfo-push.sh
@@ -121,6 +121,43 @@ test_expect_success 'check cherry-pick mergeinfo' '
/branches/svnb5:6,11"
'
+test_expect_success 'make further commits to branch' '
+ git checkout svnb1 &&
+ mkdir sub_directory &&
+ touch sub_directory/newb1file &&
+ git add sub_directory/newb1file &&
+ git commit -m "sub directory b1 commit" &&
+ git svn dcommit &&
+ git checkout svnb2 &&
+ mkdir sub_directory &&
+ touch sub_directory/newb2file &&
+ git add sub_directory/newb2file &&
+ git commit -m "sub directory b2 commit" &&
+ touch sub_directory/newb2file2 &&
+ git add sub_directory/newb2file2 &&
+ git commit -m "sub directory b2 commit 2" &&
+ git svn dcommit
+ '
+
+test_expect_success 'cherry-pick mergeinfo sub directory' '
+ git config svn.mergeinfopath sub_directory &&
+ git checkout svnb1 &&
+ git cherry-pick svnb2 &&
+ git cherry-pick svnb2^ &&
+ git svn dcommit &&
+ git config --unset svn.mergeinfopath
+ '
+
+test_expect_success 'check cherry-pick mergeinfo sub directory' '
+ mergeinfo=$(svn_cmd propget svn:mergeinfo "$svnrepo"/branches/svnb1)
+ test "$mergeinfo" = "/branches/svnb2:3,8,16-17,20-22
+/branches/svnb3:4,9
+/branches/svnb4:5-6,10-12
+/branches/svnb5:6,11" &&
+ mergeinfo=$(cd sub_directory && svn_cmd propget svn:mergeinfo "$svnrepo"/branches/svnb1/sub_directory) &&
+ test "$mergeinfo" = "/branches/svnb2/sub_directory:27-28"
+ '
+
test_expect_success 'dcommit a merge at the top of a stack' '
git checkout svnb1 &&
touch anotherfile &&
--
1.8.5.rc3.5.g96ccada
prev parent reply other threads:[~2013-11-28 15:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-28 15:52 [RFC 0/3] git-svn: Add support for cherry-pick merges Andrew Wong
2013-11-28 15:52 ` [RFC 1/3] git-svn: Generate mergeinfo for every commit Andrew Wong
2013-11-28 15:52 ` [RFC 2/3] git-svn: Support cherry-pick merges Andrew Wong
2013-11-28 15:52 ` Andrew Wong [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1385653937-29595-4-git-send-email-andrew.kw.w@gmail.com \
--to=andrew.kw.w@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).