Skip to content

Commit f271fad

Browse files
srwalterEric Wong
authored andcommitted
git-svn.perl: consider all ranges for a given merge, instead of only tip-by-tip
Consider the case where you have trunk, branch1 of trunk, and branch2 of branch1. trunk is merged back into branch2, and then branch2 is reintegrated into trunk. The merge of branch2 into trunk will have svn:mergeinfo property references to both branch1 and branch2. When git-svn fetches the commit that merges branch2 (check_cherry_pick), it is necessary to eliminate the merged contents of branch1 as well as branch2, or else the merge will be incorrectly ignored as a cherry-pick. Signed-off-by: Steven Walter <[email protected]> Reviewed-by: Sam Vilain <[email protected]> Signed-off-by: Eric Wong <[email protected]>
1 parent f84667d commit f271fad

File tree

2 files changed

+63
-5
lines changed

2 files changed

+63
-5
lines changed

perl/Git/SVN.pm

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,14 +1713,14 @@ sub find_extra_svn_parents {
17131713
my @merge_tips;
17141714
my $url = $self->url;
17151715
my $uuid = $self->ra_uuid;
1716-
my %ranges;
1716+
my @all_ranges;
17171717
for my $merge ( @merges ) {
17181718
my ($tip_commit, @ranges) =
17191719
lookup_svn_merge( $uuid, $url, $merge );
17201720
unless (!$tip_commit or
17211721
grep { $_ eq $tip_commit } @$parents ) {
17221722
push @merge_tips, $tip_commit;
1723-
$ranges{$tip_commit} = \@ranges;
1723+
push @all_ranges, @ranges;
17241724
} else {
17251725
push @merge_tips, undef;
17261726
}
@@ -1735,8 +1735,6 @@ sub find_extra_svn_parents {
17351735
my $spec = shift @merges;
17361736
next unless $merge_tip and $excluded{$merge_tip};
17371737

1738-
my $ranges = $ranges{$merge_tip};
1739-
17401738
# check out 'new' tips
17411739
my $merge_base;
17421740
eval {
@@ -1758,7 +1756,7 @@ sub find_extra_svn_parents {
17581756
my (@incomplete) = check_cherry_pick(
17591757
$merge_base, $merge_tip,
17601758
$parents,
1761-
@$ranges,
1759+
@all_ranges,
17621760
);
17631761

17641762
if ( @incomplete ) {
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/sh
2+
#
3+
# Copyright (c) 2012 Steven Walter
4+
#
5+
6+
test_description='git svn merge detection'
7+
. ./lib-git-svn.sh
8+
9+
svn_ver="$(svn --version --quiet)"
10+
case $svn_ver in
11+
0.* | 1.[0-4].*)
12+
skip_all="skipping git-svn test - SVN too old ($svn_ver)"
13+
test_done
14+
;;
15+
esac
16+
17+
test_expect_success 'initialize source svn repo' '
18+
svn_cmd mkdir -m x "$svnrepo"/trunk &&
19+
svn_cmd mkdir -m x "$svnrepo"/branches &&
20+
svn_cmd co "$svnrepo"/trunk "$SVN_TREE" &&
21+
(
22+
cd "$SVN_TREE" &&
23+
touch foo &&
24+
svn_cmd add foo &&
25+
svn_cmd commit -m "initial commit" &&
26+
svn_cmd cp -m branch "$svnrepo"/trunk "$svnrepo"/branches/branch1 &&
27+
svn_cmd switch "$svnrepo"/branches/branch1 &&
28+
touch bar &&
29+
svn_cmd add bar &&
30+
svn_cmd commit -m branch1 &&
31+
svn_cmd cp -m branch "$svnrepo"/branches/branch1 "$svnrepo"/branches/branch2 &&
32+
svn_cmd switch "$svnrepo"/branches/branch2 &&
33+
touch baz &&
34+
svn_cmd add baz &&
35+
svn_cmd commit -m branch2 &&
36+
svn_cmd switch "$svnrepo"/trunk &&
37+
touch bar2 &&
38+
svn_cmd add bar2 &&
39+
svn_cmd commit -m trunk &&
40+
svn_cmd switch "$svnrepo"/branches/branch2 &&
41+
svn_cmd merge "$svnrepo"/trunk &&
42+
svn_cmd commit -m "merge trunk"
43+
svn_cmd switch "$svnrepo"/trunk &&
44+
svn_cmd merge --reintegrate "$svnrepo"/branches/branch2 &&
45+
svn_cmd commit -m "merge branch2"
46+
) &&
47+
rm -rf "$SVN_TREE"
48+
'
49+
50+
test_expect_success 'clone svn repo' '
51+
git svn init -s "$svnrepo" &&
52+
git svn fetch
53+
'
54+
55+
test_expect_success 'verify merge commit' 'x=$(git rev-parse HEAD^2) &&
56+
y=$(git rev-parse branch2) &&
57+
test "x$x" = "x$y"
58+
'
59+
60+
test_done

0 commit comments

Comments
 (0)