git-svn: check_cherry_pick should exclude commits already in our history
The merge-base between @$parents and $merge_tip may have been reached through a merge commit. This means that some commits that are ancestors of @$parents will not be ancestors of $merge_base. The mergeinfo property will not list commits that are ancestors of @$parents, so we need to explicitly exclude them. [ew: squashed and cleaned up test case from Steven] Signed-off-by: Steven Walter <stevenrwalter@gmail.com> Acked-by: Eric Wong <normalperson@yhbt.net>
Steven Walter committed
Sep 2, 2010 at 18:32 UTC
a3c75056dc73661a6cdab180659f52cdb03b357c
2 files changed
+53
-1
git-svn.perl
+3
-1
@@ -3118,9 +3118,10 @@ sub _rev_list {
3118
sub check_cherry_pick {
3119
my $base = shift;
3120
my $tip = shift;
3121
+ my $parents = shift;
3122
my @ranges = @_;
3123
my %commits = map { $_ => 1 }
3123
- _rev_list("--no-merges", $tip, "--not", $base);
3124
+ _rev_list("--no-merges", $tip, "--not", $base, @$parents);
3125
for my $range ( @ranges ) {
3126
delete @commits{_rev_list($range)};
3127
}
@@ -3296,6 +3297,7 @@ sub find_extra_svn_parents {
3297
# double check that there are no missing non-merge commits
3298
my (@incomplete) = check_cherry_pick(
3299
$merge_base, $merge_tip,
3300
+ $parents,
3301
@$ranges,
3302
);
3303
t/t9157-git-svn-fetch-merge.sh
new
+50
@@ -0,0 +1,50 @@
1
+#!/bin/sh
2
+#
3
+# Copyright (c) 2010 Steven Walter
4
+#
5
+
6
+test_description='git svn merge detection'
7
+. ./lib-git-svn.sh
8
+
9
+test_expect_success 'initialize source svn repo' '
10
+ svn_cmd mkdir -m x "$svnrepo"/trunk &&
11
+ svn_cmd mkdir -m x "$svnrepo"/branches &&
12
+ svn_cmd co "$svnrepo"/trunk "$SVN_TREE" &&
13
+ (
14
+ cd "$SVN_TREE" &&
15
+ touch foo &&
16
+ svn add foo &&
17
+ svn commit -m "initial commit" &&
18
+ svn cp -m branch "$svnrepo"/trunk "$svnrepo"/branches/branch1 &&
19
+ touch bar &&
20
+ svn add bar &&
21
+ svn commit -m x &&
22
+ svn cp -m branch "$svnrepo"/trunk "$svnrepo"/branches/branch2 &&
23
+ svn switch "$svnrepo"/branches/branch1 &&
24
+ touch baz &&
25
+ svn add baz &&
26
+ svn commit -m x &&
27
+ svn switch "$svnrepo"/trunk &&
28
+ svn merge "$svnrepo"/branches/branch1 &&
29
+ svn commit -m "merge" &&
30
+ svn switch "$svnrepo"/branches/branch1 &&
31
+ svn commit -m x &&
32
+ svn switch "$svnrepo"/branches/branch2 &&
33
+ svn merge "$svnrepo"/branches/branch1 &&
34
+ svn commit -m "merge branch1" &&
35
+ svn switch "$svnrepo"/trunk &&
36
+ svn merge "$svnrepo"/branches/branch2 &&
37
+ svn resolved baz &&
38
+ svn commit -m "merge branch2"
39
+ ) &&
40
+ rm -rf "$SVN_TREE"
41
+'
42
+
43
+test_expect_success 'clone svn repo' '
44
+ git svn init -s "$svnrepo" &&
45
+ git svn fetch
46
+'
47
+
48
+test_expect_success 'verify merge commit' 'git rev-parse HEAD^2'
49
+
50
+test_done