threads / patch / 22751

patch, 3 partst9151: Add two new svn:mergeinfo test cases

Subject: [PATCH 2/3] t9151: Add two new svn:mergeinfo test cases

## tl;dr

10 messages between Feb 22, 2010 and Feb 26, 2010. Diffs are folded; open one to read it.

replies: 9people: 4as markdown or json

Tuomas Suutari· Feb 22, 2010, 07:57 UTC · lore

git-svn detects some merges incorrectly from svn:mergeinfo

Hi,

Now that git-svn detects merges from svn:mergeinfo, I thought it's time to re-import some of my SVN repos with git-svn. Detecting of the merges worked mostly well, but when inspecting the imported history with gitk, I found some incorrectly detected merges.

This patch series adds a test case and a fix for the case.

I was a bit uncertain if the fix should go to parents_exclude function or to "cater for merges which merge commits from multiple branches" section of find_extra_svn_parents function. I chose the latter and at least it does the trick.

-- 
Tuomas
Tuomas Suutari· Feb 22, 2010, 07:57 UTC · re: Tuomas Suutari · lore

[PATCH 1/3] t9151: Fix a few commits in the SVN dump

A few "svn cp" commands and commit commands were executed in incorrect order. Therefore some of the desired commits were missing and some were committed with wrong revision number in the commit message. This made it hard to compare the produced git repository with the SVN repository.

The dump file is updated too, but only the relevant parts and with hand-edited timestamps to make history linear.

Signed-off-by: Tuomas Suutari <tuomas.suutari@gmail.com>
---
 t/t9151/make-svnmerge-dump |    6 +-
 t/t9151/svn-mergeinfo.dump |  106 +++++++++++++++++++++++++++++--------------
 2 files changed, 74 insertions(+), 38 deletions(-)
Show changes to 2 files +74 −38

t/t9151/make-svnmerge-dump, t/t9151/svn-mergeinfo.dump

diff --git a/t/t9151/make-svnmerge-dump b/t/t9151/make-svnmerge-dump
index 3d73f14..3168c7c 100644
--- a/t/t9151/make-svnmerge-dump
+++ b/t/t9151/make-svnmerge-dump
@@ -174,8 +174,8 @@ cd ..
 
 say "Make PARTIAL branch"
 svn update
-i=$(commit $i "make partial branch")
 svn cp trunk/subdir branches/partial
+i=$(commit $i "make partial branch")
 
 say "Make a commit to PARTIAL"
 svn update
@@ -194,13 +194,13 @@ cd ../../
 
 say "Tagging trunk"
 svn update
-i=$(commit $i "tagging v1.0")
 svn cp trunk tags/v1.0
+i=$(commit $i "tagging v1.0")
 
 say "Branching BUGFIX from v1.0"
 svn update
-i=$(commit $i "make bugfix branch from tag")
 svn cp tags/v1.0 branches/bugfix
+i=$(commit $i "make bugfix branch from tag")
 
 say "Make a commit to BUGFIX"
 svn update
diff --git a/t/t9151/svn-mergeinfo.dump b/t/t9151/svn-mergeinfo.dump
index ebf386e..f228958 100644
--- a/t/t9151/svn-mergeinfo.dump
+++ b/t/t9151/svn-mergeinfo.dump
@@ -1713,13 +1713,13 @@ Node-copyfrom-path: branches/left/subdir
 
 
 Revision-number: 27
-Prop-content-length: 118
-Content-length: 118
+Prop-content-length: 123
+Content-length: 123
 
 K 7
 svn:log
-V 20
-(r28) partial update
+V 25
+(r27) make partial branch
 K 10
 svn:author
 V 3
@@ -1737,6 +1737,24 @@ Node-copyfrom-rev: 26
 Node-copyfrom-path: trunk/subdir
 
 
+Revision-number: 28
+Prop-content-length: 118
+Content-length: 118
+
+K 7
+svn:log
+V 20
+(r28) partial update
+K 10
+svn:author
+V 3
+adm
+K 8
+svn:date
+V 27
+2010-01-19T04:14:54.000000Z
+PROPS-END
+
 Node-path: branches/partial/palindromes
 Node-kind: file
 Node-action: add
@@ -1750,7 +1768,7 @@ PROPS-END
 racecar
 
 
-Revision-number: 28
+Revision-number: 29
 Prop-content-length: 126
 Content-length: 126
 
@@ -1771,15 +1789,15 @@ PROPS-END
 Node-path: trunk/subdir
 Node-kind: dir
 Node-action: change
-Prop-content-length: 142
-Content-length: 142
+Prop-content-length: 145
+Content-length: 145
 
 K 13
 svn:mergeinfo
-V 106
+V 109
 /branches/left/subdir:2-25
 /branches/left-sub/subdir:4-19
-/branches/partial:27
+/branches/partial:27-28
 /branches/right/subdir:2-22
 PROPS-END
 
@@ -1787,20 +1805,20 @@ PROPS-END
 Node-path: trunk/subdir/palindromes
 Node-kind: file
 Node-action: add
-Node-copyfrom-rev: 27
+Node-copyfrom-rev: 28
 Node-copyfrom-path: branches/partial/palindromes
 Text-copy-source-md5: 5d1c2024fb5efc4eef812856df1b080c
 Text-copy-source-sha1: 5f8509ddd14c91a52864dd1447344e706f9bbc69
 
 
-Revision-number: 29
-Prop-content-length: 131
-Content-length: 131
+Revision-number: 30
+Prop-content-length: 116
+Content-length: 116
 
 K 7
 svn:log
-V 33
-(r31) make bugfix branch from tag
+V 18
+(r30) tagging v1.0
 K 10
 svn:author
 V 3
@@ -1814,18 +1832,18 @@ PROPS-END
 Node-path: tags/v1.0
 Node-kind: dir
 Node-action: add
-Node-copyfrom-rev: 28
+Node-copyfrom-rev: 29
 Node-copyfrom-path: trunk
 
 
-Revision-number: 30
-Prop-content-length: 120
-Content-length: 120
+Revision-number: 31
+Prop-content-length: 131
+Content-length: 131
 
 K 7
 svn:log
-V 22
-(r32) commit to bugfix
+V 33
+(r31) make bugfix branch from tag
 K 10
 svn:author
 V 3
@@ -1833,16 +1851,34 @@ adm
 K 8
 svn:date
 V 27
-2010-01-19T04:15:03.043218Z
+2010-01-19T04:15:01.000000Z
 PROPS-END
 
 Node-path: branches/bugfix
 Node-kind: dir
 Node-action: add
-Node-copyfrom-rev: 29
+Node-copyfrom-rev: 30
 Node-copyfrom-path: tags/v1.0
 
 
+Revision-number: 32
+Prop-content-length: 120
+Content-length: 120
+
+K 7
+svn:log
+V 22
+(r32) commit to bugfix
+K 10
+svn:author
+V 3
+adm
+K 8
+svn:date
+V 27
+2010-01-19T04:15:02.000000Z
+PROPS-END
+
 Node-path: branches/bugfix/subdir/palindromes
 Node-kind: file
 Node-action: change
@@ -1855,7 +1891,7 @@ racecar
 kayak
 
 
-Revision-number: 31
+Revision-number: 33
 Prop-content-length: 125
 Content-length: 125
 
@@ -1876,35 +1912,35 @@ PROPS-END
 Node-path: trunk
 Node-kind: dir
 Node-action: change
-Prop-content-length: 133
-Content-length: 133
+Prop-content-length: 137
+Content-length: 137
 
 K 13
 svn:mergeinfo
-V 98
-/branches/bugfix:30
+V 101
+/branches/bugfix:31-32
 /branches/left:2-25
 /branches/left-sub:4-19
 /branches/right:2-22
-/tags/v1.0:29
+/tags/v1.0:30
 PROPS-END
 
 
 Node-path: trunk/subdir
 Node-kind: dir
 Node-action: change
-Prop-content-length: 190
-Content-length: 190
+Prop-content-length: 196
+Content-length: 196
 
 K 13
 svn:mergeinfo
-V 154
-/branches/bugfix/subdir:30
+V 160
+/branches/bugfix/subdir:31-32
 /branches/left/subdir:2-25
 /branches/left-sub/subdir:4-19
-/branches/partial:27
+/branches/partial:27-28
 /branches/right/subdir:2-22
-/tags/v1.0/subdir:29
+/tags/v1.0/subdir:30
 PROPS-END
 
 
-- 
1.7.0.86.g7501
Sam Vilain· Feb 24, 2010, 23:14 UTC · re: Tuomas Suutari · lore

Re: [PATCH 1/3] t9151: Fix a few commits in the SVN dump

Tuomas Suutari wrote:
Show 9 quoted lines
> A few "svn cp" commands and commit commands were executed in incorrect
> order. Therefore some of the desired commits were missing and some
> were committed with wrong revision number in the commit message. This
> made it hard to compare the produced git repository with the SVN
> repository.
>
> The dump file is updated too, but only the relevant parts and with
> hand-edited timestamps to make history linear.
>   
Show 16 quoted lines
>  say "Make PARTIAL branch"
>  svn update
> -i=$(commit $i "make partial branch")
>  svn cp trunk/subdir branches/partial
> +i=$(commit $i "make partial branch")
>  
>  say "Make a commit to PARTIAL"
>  svn update
> @@ -194,13 +194,13 @@ cd ../../
>  
>  say "Tagging trunk"
>  svn update
> -i=$(commit $i "tagging v1.0")
>  svn cp trunk tags/v1.0
> +i=$(commit $i "tagging v1.0")
>   
Whoops.  Yes, that looks eminently sensible, probably my fault :-).
Acked-by: Sam Vilain <sam@vilain.net>
Sam
Tuomas Suutari· Feb 22, 2010, 07:57 UTC · re: Tuomas Suutari · lore

When svn:mergeinfo contains two new parents in a specific order and one is ancestor of the other, it is possible that git-svn discards the wrong one. The first test case ("commit made to merged branch is reachable from the merge") proves this.

The second test case ("merging two branches in one commit is detected correctly") is just for completeness, since there was no test for merging two (feature) branches to trunk in one commit.

Signed-off-by: Tuomas Suutari <tuomas.suutari@gmail.com>
---
 t/t9151-svn-mergeinfo.sh   |   15 ++
 t/t9151/make-svnmerge-dump |   83 +++++++
 t/t9151/svn-mergeinfo.dump |  536 +++++++++++++++++++++++++++++++++++++++-----
 3 files changed, 581 insertions(+), 53 deletions(-)
Show changes to 3 files +581 −53

t/t9151-svn-mergeinfo.sh, t/t9151/make-svnmerge-dump, t/t9151/svn-mergeinfo.dump

diff --git a/t/t9151-svn-mergeinfo.sh b/t/t9151-svn-mergeinfo.sh
index 3569c62..353f543 100755
--- a/t/t9151-svn-mergeinfo.sh
+++ b/t/t9151-svn-mergeinfo.sh
@@ -33,6 +33,21 @@ test_expect_success 'svn non-merge merge commits did not become git merge commit
 	[ -z "$bad_non_merges" ]
 	'
 
+test_expect_failure 'commit made to merged branch is reachable from the merge' '
+	before_commit=$(git rev-list --all --grep="trunk commit before merging trunk to b2")
+	merge_commit=$(git rev-list --all --grep="Merge trunk to b2")
+	not_reachable=$(git rev-list -1 $before_commit --not $merge_commit)
+	[ -z "$not_reachable" ]
+	'
+
+test_expect_success 'merging two branches in one commit is detected correctly' '
+	f1_commit=$(git rev-list --all --grep="make f1 branch from trunk")
+	f2_commit=$(git rev-list --all --grep="make f2 branch from trunk")
+	merge_commit=$(git rev-list --all --grep="Merge f1 and f2 to trunk")
+	not_reachable=$(git rev-list -1 $f1_commit $f2_commit --not $merge_commit)
+	[ -z "$not_reachable" ]
+	'
+
 test_expect_failure 'everything got merged in the end' '
 	unmerged=$(git rev-list --all --not master)
 	[ -z "$unmerged" ]
diff --git a/t/t9151/make-svnmerge-dump b/t/t9151/make-svnmerge-dump
index 3168c7c..e1e138c 100644
--- a/t/t9151/make-svnmerge-dump
+++ b/t/t9151/make-svnmerge-dump
@@ -156,6 +156,89 @@ svn merge ../branches/right --accept postpone
 i=$(commit $i "non-merge right to trunk 2")
 cd ..
 
+say "Branching b1 from trunk"
+svn update
+svn cp trunk branches/b1
+i=$(commit $i "make b1 branch from trunk")
+
+say "Branching b2 from trunk"
+svn update
+svn cp trunk branches/b2
+i=$(commit $i "make b2 branch from trunk")
+
+say "Make a commit to b2"
+svn update
+cd branches/b2
+echo "b2" > b2file
+svn add b2file
+i=$(commit $i "b2 update 1")
+cd ../..
+
+say "Make a commit to b1"
+svn update
+cd branches/b1
+echo "b1" > b1file
+svn add b1file
+i=$(commit $i "b1 update 1")
+cd ../..
+
+say "Merge b1 to trunk"
+svn update
+cd trunk
+svn merge ../branches/b1/ --accept postpone
+i=$(commit $i "Merge b1 to trunk")
+cd ..
+
+say "Make a commit to trunk before merging trunk to b2"
+svn update
+cd trunk
+echo "trunk" > trunkfile
+svn add trunkfile
+i=$(commit $i "trunk commit before merging trunk to b2")
+cd ..
+
+say "Merge trunk to b2"
+svn update
+cd branches/b2
+svn merge ../../trunk/ --accept postpone
+i=$(commit $i "Merge trunk to b2")
+cd ../..
+
+say "Merge b2 to trunk"
+svn update
+cd trunk
+svn merge ../branches/b2/ --accept postpone
+svn resolved b1file
+svn resolved trunkfile
+i=$(commit $i "Merge b2 to trunk")
+cd ..
+
+say "Creating f1 from trunk with a new file"
+svn update
+svn cp trunk branches/f1
+cd branches/f1
+echo "f1" > f1file
+svn add f1file
+cd ../..
+i=$(commit $i "make f1 branch from trunk with a new file")
+
+say "Creating f2 from trunk with a new file"
+svn update
+svn cp trunk branches/f2
+cd branches/f2
+echo "f2" > f2file
+svn add f2file
+cd ../..
+i=$(commit $i "make f2 branch from trunk with a new file")
+
+say "Merge f1 and f2 to trunk in one go"
+svn update
+cd trunk
+svn merge ../branches/f1/ --accept postpone
+svn merge ../branches/f2/ --accept postpone
+i=$(commit $i "Merge f1 and f2 to trunk")
+cd ..
+
 say "Adding subdirectory to LEFT"
 svn update
 cd branches/left
diff --git a/t/t9151/svn-mergeinfo.dump b/t/t9151/svn-mergeinfo.dump
index f228958..47cafcf 100644
--- a/t/t9151/svn-mergeinfo.dump
+++ b/t/t9151/svn-mergeinfo.dump
@@ -1633,13 +1633,427 @@ PROPS-END
 
 
 Revision-number: 25
+Prop-content-length: 129
+Content-length: 129
+
+K 7
+svn:log
+V 31
+(r25) make b1 branch from trunk
+K 10
+svn:author
+V 3
+adm
+K 8
+svn:date
+V 27
+2010-02-22T06:18:56.084589Z
+PROPS-END
+
+Node-path: branches/b1
+Node-kind: dir
+Node-action: add
+Node-copyfrom-rev: 24
+Node-copyfrom-path: trunk
+
+
+Revision-number: 26
+Prop-content-length: 129
+Content-length: 129
+
+K 7
+svn:log
+V 31
+(r26) make b2 branch from trunk
+K 10
+svn:author
+V 3
+adm
+K 8
+svn:date
+V 27
+2010-02-22T06:18:59.076940Z
+PROPS-END
+
+Node-path: branches/b2
+Node-kind: dir
+Node-action: add
+Node-copyfrom-rev: 25
+Node-copyfrom-path: trunk
+
+
+Revision-number: 27
+Prop-content-length: 115
+Content-length: 115
+
+K 7
+svn:log
+V 17
+(r27) b2 update 1
+K 10
+svn:author
+V 3
+adm
+K 8
+svn:date
+V 27
+2010-02-22T06:19:01.095762Z
+PROPS-END
+
+Node-path: branches/b2/b2file
+Node-kind: file
+Node-action: add
+Prop-content-length: 10
+Text-content-length: 3
+Text-content-md5: 5edbdd57cba621eb3c6e601bf563b4dc
+Text-content-sha1: 9d4b38049776bd0a2074d67cad23f8eaed35a3b3
+Content-length: 13
+
+PROPS-END
+b2
+
+
+Revision-number: 28
+Prop-content-length: 115
+Content-length: 115
+
+K 7
+svn:log
+V 17
+(r28) b1 update 1
+K 10
+svn:author
+V 3
+adm
+K 8
+svn:date
+V 27
+2010-02-22T06:19:03.097465Z
+PROPS-END
+
+Node-path: branches/b1/b1file
+Node-kind: file
+Node-action: add
+Prop-content-length: 10
+Text-content-length: 3
+Text-content-md5: 08778dfd9ac4f603231896aba7aad523
+Text-content-sha1: b551771aa4ad5b14123fc3bd98d89db2bc0edd4f
+Content-length: 13
+
+PROPS-END
+b1
+
+
+Revision-number: 29
+Prop-content-length: 121
+Content-length: 121
+
+K 7
+svn:log
+V 23
+(r29) Merge b1 to trunk
+K 10
+svn:author
+V 3
+adm
+K 8
+svn:date
+V 27
+2010-02-22T06:19:06.073175Z
+PROPS-END
+
+Node-path: trunk
+Node-kind: dir
+Node-action: change
+Prop-content-length: 118
+Content-length: 118
+
+K 13
+svn:mergeinfo
+V 83
+/branches/b1:25-28
+/branches/left:2-22
+/branches/left-sub:4-19
+/branches/right:2-22
+PROPS-END
+
+
+Node-path: trunk/b1file
+Node-kind: file
+Node-action: add
+Node-copyfrom-rev: 28
+Node-copyfrom-path: branches/b1/b1file
+Text-copy-source-md5: 08778dfd9ac4f603231896aba7aad523
+Text-copy-source-sha1: b551771aa4ad5b14123fc3bd98d89db2bc0edd4f
+
+
+Revision-number: 30
+Prop-content-length: 143
+Content-length: 143
+
+K 7
+svn:log
+V 45
+(r30) trunk commit before merging trunk to b2
+K 10
+svn:author
+V 3
+adm
+K 8
+svn:date
+V 27
+2010-02-22T06:19:08.096353Z
+PROPS-END
+
+Node-path: trunk/trunkfile
+Node-kind: file
+Node-action: add
+Prop-content-length: 10
+Text-content-length: 6
+Text-content-md5: edf45fe5c98c5367733b39bbb2bb20d9
+Text-content-sha1: 7361d1685e5c86dfc523620cfaf598f196f86239
+Content-length: 16
+
+PROPS-END
+trunk
+
+
+Revision-number: 31
+Prop-content-length: 121
+Content-length: 121
+
+K 7
+svn:log
+V 23
+(r31) Merge trunk to b2
+K 10
+svn:author
+V 3
+adm
+K 8
+svn:date
+V 27
+2010-02-22T06:19:11.081541Z
+PROPS-END
+
+Node-path: branches/b2
+Node-kind: dir
+Node-action: change
+Prop-content-length: 131
+Content-length: 131
+
+K 13
+svn:mergeinfo
+V 96
+/branches/b1:25-28
+/branches/left:2-22
+/branches/left-sub:4-19
+/branches/right:2-22
+/trunk:26-30
+PROPS-END
+
+
+Node-path: branches/b2/b1file
+Node-kind: file
+Node-action: add
+Node-copyfrom-rev: 30
+Node-copyfrom-path: trunk/b1file
+Text-copy-source-md5: 08778dfd9ac4f603231896aba7aad523
+Text-copy-source-sha1: b551771aa4ad5b14123fc3bd98d89db2bc0edd4f
+
+
+Node-path: branches/b2/trunkfile
+Node-kind: file
+Node-action: add
+Node-copyfrom-rev: 30
+Node-copyfrom-path: trunk/trunkfile
+Text-copy-source-md5: edf45fe5c98c5367733b39bbb2bb20d9
+Text-copy-source-sha1: 7361d1685e5c86dfc523620cfaf598f196f86239
+
+
+Revision-number: 32
+Prop-content-length: 121
+Content-length: 121
+
+K 7
+svn:log
+V 23
+(r32) Merge b2 to trunk
+K 10
+svn:author
+V 3
+adm
+K 8
+svn:date
+V 27
+2010-02-22T06:19:14.117939Z
+PROPS-END
+
+Node-path: trunk
+Node-kind: dir
+Node-action: change
+Prop-content-length: 138
+Content-length: 138
+
+K 13
+svn:mergeinfo
+V 102
+/branches/b1:25-28
+/branches/b2:26-31
+/branches/left:2-22
+/branches/left-sub:4-19
+/branches/right:2-22
+PROPS-END
+
+
+Node-path: trunk/b2file
+Node-kind: file
+Node-action: add
+Node-copyfrom-rev: 31
+Node-copyfrom-path: branches/b2/b2file
+Text-copy-source-md5: 5edbdd57cba621eb3c6e601bf563b4dc
+Text-copy-source-sha1: 9d4b38049776bd0a2074d67cad23f8eaed35a3b3
+
+
+Revision-number: 33
+Prop-content-length: 145
+Content-length: 145
+
+K 7
+svn:log
+V 47
+(r33) make f1 branch from trunk with a new file
+K 10
+svn:author
+V 3
+adm
+K 8
+svn:date
+V 27
+2010-02-22T06:19:17.105832Z
+PROPS-END
+
+Node-path: branches/f1
+Node-kind: dir
+Node-action: add
+Node-copyfrom-rev: 32
+Node-copyfrom-path: trunk
+
+
+Node-path: branches/f1/f1file
+Node-kind: file
+Node-action: add
+Prop-content-length: 10
+Text-content-length: 3
+Text-content-md5: 2b1abc6b6c5c0018851f9f8e6475563b
+Text-content-sha1: aece6dfba588900e00d95601d22b4408d49580af
+Content-length: 13
+
+PROPS-END
+f1
+
+
+Revision-number: 34
+Prop-content-length: 145
+Content-length: 145
+
+K 7
+svn:log
+V 47
+(r34) make f2 branch from trunk with a new file
+K 10
+svn:author
+V 3
+adm
+K 8
+svn:date
+V 27
+2010-02-22T06:19:20.110057Z
+PROPS-END
+
+Node-path: branches/f2
+Node-kind: dir
+Node-action: add
+Node-copyfrom-rev: 33
+Node-copyfrom-path: trunk
+
+
+Node-path: branches/f2/f2file
+Node-kind: file
+Node-action: add
+Prop-content-length: 10
+Text-content-length: 3
+Text-content-md5: 575c5638d60271457e54ab7d07309502
+Text-content-sha1: 1c49a440c352f3473efa9512255033b94dc7def0
+Content-length: 13
+
+PROPS-END
+f2
+
+
+Revision-number: 35
+Prop-content-length: 128
+Content-length: 128
+
+K 7
+svn:log
+V 30
+(r35) Merge f1 and f2 to trunk
+K 10
+svn:author
+V 3
+adm
+K 8
+svn:date
+V 27
+2010-02-22T06:19:24.081490Z
+PROPS-END
+
+Node-path: trunk
+Node-kind: dir
+Node-action: change
+Prop-content-length: 173
+Content-length: 173
+
+K 13
+svn:mergeinfo
+V 137
+/branches/b1:25-28
+/branches/b2:26-31
+/branches/f1:33-34
+/branches/f2:34
+/branches/left:2-22
+/branches/left-sub:4-19
+/branches/right:2-22
+PROPS-END
+
+
+Node-path: trunk/f1file
+Node-kind: file
+Node-action: add
+Node-copyfrom-rev: 34
+Node-copyfrom-path: branches/f1/f1file
+Text-copy-source-md5: 2b1abc6b6c5c0018851f9f8e6475563b
+Text-copy-source-sha1: aece6dfba588900e00d95601d22b4408d49580af
+
+
+Node-path: trunk/f2file
+Node-kind: file
+Node-action: add
+Node-copyfrom-rev: 34
+Node-copyfrom-path: branches/f2/f2file
+Text-copy-source-md5: 575c5638d60271457e54ab7d07309502
+Text-copy-source-sha1: 1c49a440c352f3473efa9512255033b94dc7def0
+
+
+Revision-number: 36
 Prop-content-length: 135
 Content-length: 135
 
 K 7
 svn:log
 V 37
-(r25) add subdirectory to left branch
+(r36) add subdirectory to left branch
 K 10
 svn:author
 V 3
@@ -1647,7 +2061,7 @@ adm
 K 8
 svn:date
 V 27
-2010-01-19T04:14:46.052649Z
+2010-02-22T06:19:26.113516Z
 PROPS-END
 
 Node-path: branches/left/subdir
@@ -1672,14 +2086,14 @@ PROPS-END
 Yeehaw
 
 
-Revision-number: 26
+Revision-number: 37
 Prop-content-length: 123
 Content-length: 123
 
 K 7
 svn:log
 V 25
-(r26) merge left to trunk
+(r37) merge left to trunk
 K 10
 svn:author
 V 3
@@ -1687,19 +2101,23 @@ adm
 K 8
 svn:date
 V 27
-2010-01-19T04:14:49.040783Z
+2010-02-22T06:19:29.073699Z
 PROPS-END
 
 Node-path: trunk
 Node-kind: dir
 Node-action: change
-Prop-content-length: 99
-Content-length: 99
+Prop-content-length: 173
+Content-length: 173
 
 K 13
 svn:mergeinfo
-V 64
-/branches/left:2-25
+V 137
+/branches/b1:25-28
+/branches/b2:26-31
+/branches/f1:33-34
+/branches/f2:34
+/branches/left:2-36
 /branches/left-sub:4-19
 /branches/right:2-22
 PROPS-END
@@ -1708,18 +2126,18 @@ PROPS-END
 Node-path: trunk/subdir
 Node-kind: dir
 Node-action: add
-Node-copyfrom-rev: 25
+Node-copyfrom-rev: 36
 Node-copyfrom-path: branches/left/subdir
 
 
-Revision-number: 27
+Revision-number: 38
 Prop-content-length: 123
 Content-length: 123
 
 K 7
 svn:log
 V 25
-(r27) make partial branch
+(r38) make partial branch
 K 10
 svn:author
 V 3
@@ -1727,24 +2145,24 @@ adm
 K 8
 svn:date
 V 27
-2010-01-19T04:14:53.049037Z
+2010-02-22T06:19:32.072243Z
 PROPS-END
 
 Node-path: branches/partial
 Node-kind: dir
 Node-action: add
-Node-copyfrom-rev: 26
+Node-copyfrom-rev: 37
 Node-copyfrom-path: trunk/subdir
 
 
-Revision-number: 28
+Revision-number: 39
 Prop-content-length: 118
 Content-length: 118
 
 K 7
 svn:log
 V 20
-(r28) partial update
+(r39) partial update
 K 10
 svn:author
 V 3
@@ -1752,7 +2170,7 @@ adm
 K 8
 svn:date
 V 27
-2010-01-19T04:14:54.000000Z
+2010-02-22T06:19:34.097961Z
 PROPS-END
 
 Node-path: branches/partial/palindromes
@@ -1768,14 +2186,14 @@ PROPS-END
 racecar
 
 
-Revision-number: 29
+Revision-number: 40
 Prop-content-length: 126
 Content-length: 126
 
 K 7
 svn:log
 V 28
-(r29) merge partial to trunk
+(r40) merge partial to trunk
 K 10
 svn:author
 V 3
@@ -1783,21 +2201,25 @@ adm
 K 8
 svn:date
 V 27
-2010-01-19T04:14:56.041526Z
+2010-02-22T06:19:37.080211Z
 PROPS-END
 
 Node-path: trunk/subdir
 Node-kind: dir
 Node-action: change
-Prop-content-length: 145
-Content-length: 145
+Prop-content-length: 246
+Content-length: 246
 
 K 13
 svn:mergeinfo
-V 109
-/branches/left/subdir:2-25
+V 210
+/branches/b1/subdir:25-28
+/branches/b2/subdir:26-31
+/branches/f1/subdir:33-34
+/branches/f2/subdir:34
+/branches/left/subdir:2-36
 /branches/left-sub/subdir:4-19
-/branches/partial:27-28
+/branches/partial:38-39
 /branches/right/subdir:2-22
 PROPS-END
 
@@ -1805,20 +2227,20 @@ PROPS-END
 Node-path: trunk/subdir/palindromes
 Node-kind: file
 Node-action: add
-Node-copyfrom-rev: 28
+Node-copyfrom-rev: 39
 Node-copyfrom-path: branches/partial/palindromes
 Text-copy-source-md5: 5d1c2024fb5efc4eef812856df1b080c
 Text-copy-source-sha1: 5f8509ddd14c91a52864dd1447344e706f9bbc69
 
 
-Revision-number: 30
+Revision-number: 41
 Prop-content-length: 116
 Content-length: 116
 
 K 7
 svn:log
 V 18
-(r30) tagging v1.0
+(r41) tagging v1.0
 K 10
 svn:author
 V 3
@@ -1826,24 +2248,24 @@ adm
 K 8
 svn:date
 V 27
-2010-01-19T04:15:00.039761Z
+2010-02-22T06:19:40.083460Z
 PROPS-END
 
 Node-path: tags/v1.0
 Node-kind: dir
 Node-action: add
-Node-copyfrom-rev: 29
+Node-copyfrom-rev: 40
 Node-copyfrom-path: trunk
 
 
-Revision-number: 31
+Revision-number: 42
 Prop-content-length: 131
 Content-length: 131
 
 K 7
 svn:log
 V 33
-(r31) make bugfix branch from tag
+(r42) make bugfix branch from tag
 K 10
 svn:author
 V 3
@@ -1851,24 +2273,24 @@ adm
 K 8
 svn:date
 V 27
-2010-01-19T04:15:01.000000Z
+2010-02-22T06:19:43.118075Z
 PROPS-END
 
 Node-path: branches/bugfix
 Node-kind: dir
 Node-action: add
-Node-copyfrom-rev: 30
+Node-copyfrom-rev: 41
 Node-copyfrom-path: tags/v1.0
 
 
-Revision-number: 32
+Revision-number: 43
 Prop-content-length: 120
 Content-length: 120
 
 K 7
 svn:log
 V 22
-(r32) commit to bugfix
+(r43) commit to bugfix
 K 10
 svn:author
 V 3
@@ -1876,7 +2298,7 @@ adm
 K 8
 svn:date
 V 27
-2010-01-19T04:15:02.000000Z
+2010-02-22T06:19:45.079536Z
 PROPS-END
 
 Node-path: branches/bugfix/subdir/palindromes
@@ -1891,14 +2313,14 @@ racecar
 kayak
 
 
-Revision-number: 33
+Revision-number: 44
 Prop-content-length: 125
 Content-length: 125
 
 K 7
 svn:log
 V 27
-(r33) Merge BUGFIX to TRUNK
+(r44) Merge BUGFIX to TRUNK
 K 10
 svn:author
 V 3
@@ -1906,41 +2328,49 @@ adm
 K 8
 svn:date
 V 27
-2010-01-19T04:15:06.043723Z
+2010-02-22T06:19:48.078914Z
 PROPS-END
 
 Node-path: trunk
 Node-kind: dir
 Node-action: change
-Prop-content-length: 137
-Content-length: 137
+Prop-content-length: 210
+Content-length: 210
 
 K 13
 svn:mergeinfo
-V 101
-/branches/bugfix:31-32
-/branches/left:2-25
+V 174
+/branches/b1:25-28
+/branches/b2:26-31
+/branches/bugfix:42-43
+/branches/f1:33-34
+/branches/f2:34
+/branches/left:2-36
 /branches/left-sub:4-19
 /branches/right:2-22
-/tags/v1.0:30
+/tags/v1.0:41
 PROPS-END
 
 
 Node-path: trunk/subdir
 Node-kind: dir
 Node-action: change
-Prop-content-length: 196
-Content-length: 196
+Prop-content-length: 297
+Content-length: 297
 
 K 13
 svn:mergeinfo
-V 160
-/branches/bugfix/subdir:31-32
-/branches/left/subdir:2-25
+V 261
+/branches/b1/subdir:25-28
+/branches/b2/subdir:26-31
+/branches/bugfix/subdir:42-43
+/branches/f1/subdir:33-34
+/branches/f2/subdir:34
+/branches/left/subdir:2-36
 /branches/left-sub/subdir:4-19
-/branches/partial:27-28
+/branches/partial:38-39
 /branches/right/subdir:2-22
-/tags/v1.0/subdir:30
+/tags/v1.0/subdir:41
 PROPS-END
 
 
-- 
1.7.0.86.g7501
Tuomas Suutari· Feb 22, 2010, 07:57 UTC · re: Tuomas Suutari · lore

[PATCH 3/3] git-svn: Fix discarding of extra parents from svn:mergeinfo

Use merge-base rather than rev-list for detecting if a parent is an ancestor of another, because rev-list gives incorrect results sometimes.

Signed-off-by: Tuomas Suutari <tuomas.suutari@gmail.com>
---
 git-svn.perl             |    8 ++++----
 t/t9151-svn-mergeinfo.sh |    2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)
Show changes to 2 files +5 −5

git-svn.perl, t/t9151-svn-mergeinfo.sh

diff --git a/git-svn.perl b/git-svn.perl
index 265852f..1e2bbe5 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -3268,11 +3268,11 @@ sub find_extra_svn_parents {
 				next if $i == $j;
 				next unless $new_parents[$i];
 				next unless $new_parents[$j];
-				my $revs = command_oneline(
-					"rev-list", "-1",
-					"$new_parents[$i]..$new_parents[$j]",
+				my $mergebase = command_oneline(
+					"merge-base",
+					"$new_parents[$i]", "$new_parents[$j]",
 				       );
-				if ( !$revs ) {
+				if ( $mergebase eq $new_parents[$i] ) {
 					undef($new_parents[$i]);
 				}
 			}
diff --git a/t/t9151-svn-mergeinfo.sh b/t/t9151-svn-mergeinfo.sh
index 353f543..1640824 100755
--- a/t/t9151-svn-mergeinfo.sh
+++ b/t/t9151-svn-mergeinfo.sh
@@ -33,7 +33,7 @@ test_expect_success 'svn non-merge merge commits did not become git merge commit
 	[ -z "$bad_non_merges" ]
 	'
 
-test_expect_failure 'commit made to merged branch is reachable from the merge' '
+test_expect_success 'commit made to merged branch is reachable from the merge' '
 	before_commit=$(git rev-list --all --grep="trunk commit before merging trunk to b2")
 	merge_commit=$(git rev-list --all --grep="Merge trunk to b2")
 	not_reachable=$(git rev-list -1 $before_commit --not $merge_commit)
-- 
1.7.0.86.g7501
Thomas Rast· Feb 22, 2010, 09:57 UTC · re: Tuomas Suutari · lore

Re: [PATCH 3/3] git-svn: Fix discarding of extra parents from svn:mergeinfo

On Monday 22 February 2010 08:57:22 Tuomas Suutari wrote:
> Use merge-base rather than rev-list for detecting if a parent is an
> ancestor of another, because rev-list gives incorrect results
> sometimes.
[...]
Show 10 quoted lines
> -				my $revs = command_oneline(
> -					"rev-list", "-1",
> -					"$new_parents[$i]..$new_parents[$j]",
> +				my $mergebase = command_oneline(
> +					"merge-base",
> +					"$new_parents[$i]", "$new_parents[$j]",
>  				       );
> -				if ( !$revs ) {
> +				if ( $mergebase eq $new_parents[$i] ) {
>  					undef($new_parents[$i]);

I think you swapped the test (or I got confused, which is entirely possible). Let I = $new_parents[$i] and J = $new_parents[$j]. The old one was

  test -z "$(git rev-list -1 I..J)"

which reads "unless there are any commits on J which are not on I", i.e., it fails unless J is an ancestor of I.

But the new one is
  "$(git merge-base I J)" == I.
so suddenly I must be an ancestor of J.

Is that what you were fixing? Because I don't think the 'rev-list -1' test is any worse than the merge-base test. If it's not, please tell us what you are fixing. Either way, please change the commit message appropriately.

-- 
Thomas Rast
trast@{inf,student}.ethz.ch
Tuomas Suutari· Feb 22, 2010, 18:04 UTC · re: Thomas Rast · lore

Re: [PATCH 3/3] git-svn: Fix discarding of extra parents from svn:mergeinfo

On Mon 2010-02-22 11:57:34 Thomas Rast wrote:
Show 5 quoted lines
> On Monday 22 February 2010 08:57:22 Tuomas Suutari wrote:
> > Use merge-base rather than rev-list for detecting if a parent is an
> > ancestor of another, because rev-list gives incorrect results
> > sometimes.
> 
[...]
> 
> I think you swapped the test (or I got confused, which is entirely
> possible).

Ah, seems so. I was already writing a long reply explaining why rev-list can't be used but only merge-base just to realize that, indeed, rev-list can be used after all. The code just used to discard the wrong parent.

Show 15 quoted lines
> Let I = $new_parents[$i] and J = $new_parents[$j].  The
> old one was
> 
>   test -z "$(git rev-list -1 I..J)"
> 
> which reads "unless there are any commits on J which are not on I",
> i.e., it fails unless J is an ancestor of I.
>
> But the new one is
> 
>   "$(git merge-base I J)" == I.
> 
> so suddenly I must be an ancestor of J.
>
> Is that what you were fixing?
Yes.
> Because I don't think the 'rev-list -1'
> test is any worse than the merge-base test.

You're right. I failed to see that I can get the same results by swapping $i with $j in the undef($new_parents[$i]) statement.

My pitfall was that I considered only changing the "if ( !$revs )" part to "if ( $revs )" with the rev-list approach. That wouldn't have worked, because then the other test case, included in PATCH 2, would have failed. (When there are two distinct branches merged to one.)

> If it's not, please tell
> us what you are fixing.  Either way, please change the commit message
> appropriately.

Yes, the commit message was horrible. I was hoping that, by writing a test case as a "description" about the problem, I would avoid writing so much English... ;)

I will send another patch soon. Hopefully with better commit message.
-- 
Tuomas
Tuomas Suutari· Feb 22, 2010, 18:12 UTC · re: Tuomas Suutari · lore

[PATCH 3/3 v2] git-svn: Fix discarding of extra parents from svn:mergeinfo

If parent J is an ancestor of parent I, then parent J should be discarded, not I.

Note that J is an ancestor of I if and only if rev-list I..J is emtpy, which is what we are testing here.

Signed-off-by: Tuomas Suutari <tuomas.suutari@gmail.com>
---
Thanks to Thomas Rast for pointing out that this can be made with a
smaller change and there is no need swap rev-list to merge-base after
all.
 git-svn.perl             |    2 +-
 t/t9151-svn-mergeinfo.sh |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Show changes to 2 files +2 −2

git-svn.perl, t/t9151-svn-mergeinfo.sh

diff --git a/git-svn.perl b/git-svn.perl
index 265852f..ed96a03 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -3273,7 +3273,7 @@ sub find_extra_svn_parents {
 					"$new_parents[$i]..$new_parents[$j]",
 				       );
 				if ( !$revs ) {
-					undef($new_parents[$i]);
+					undef($new_parents[$j]);
 				}
 			}
 		}
diff --git a/t/t9151-svn-mergeinfo.sh b/t/t9151-svn-mergeinfo.sh
index 353f543..1640824 100755
--- a/t/t9151-svn-mergeinfo.sh
+++ b/t/t9151-svn-mergeinfo.sh
@@ -33,7 +33,7 @@ test_expect_success 'svn non-merge merge commits did not become git merge commit
 	[ -z "$bad_non_merges" ]
 	'
 
-test_expect_failure 'commit made to merged branch is reachable from the merge' '
+test_expect_success 'commit made to merged branch is reachable from the merge' '
 	before_commit=$(git rev-list --all --grep="trunk commit before merging trunk to b2")
 	merge_commit=$(git rev-list --all --grep="Merge trunk to b2")
 	not_reachable=$(git rev-list -1 $before_commit --not $merge_commit)
-- 
1.7.0.87.g6166f6d.dirty
Thomas Rast· Feb 23, 2010, 16:58 UTC · re: Tuomas Suutari · lore

Re: [PATCH 3/3 v2] git-svn: Fix discarding of extra parents from svn:mergeinfo

On Monday 22 February 2010 19:12:53 Tuomas Suutari wrote:
Show 11 quoted lines
> If parent J is an ancestor of parent I, then parent J should be
> discarded, not I.
> 
> Note that J is an ancestor of I if and only if rev-list I..J is emtpy,
> which is what we are testing here.
> 
> Signed-off-by: Tuomas Suutari <tuomas.suutari@gmail.com>
> ---
> Thanks to Thomas Rast for pointing out that this can be made with a
> smaller change and there is no need swap rev-list to merge-base after
> all.
[...]
> -					undef($new_parents[$i]);
> +					undef($new_parents[$j]);
Just so this doesn't get lost...

I'm hesitating to give my "Ack", since I haven't looked into what the surrounding code does. I can't even see at a glance how the parent reduction relates to the commit that introduced it, which was

  commit 7a955a5365d9ebd5e12c12ed926b2b51b61c02ee
  Author: Sam Vilain <sam@vilain.net>
  Date:   Sun Dec 20 05:26:26 2009 +1300
      git-svn: detect cherry-picks correctly.
      The old function was incorrect; in some instances it marks a cherry picked
      range as a merged branch (because of an incorrect assumption that
      'rev-list COMMIT --not RANGE' would work).  This is replaced with a
      function which should detect them correctly, memoized to limit the expense
      of dealing with branches with many cherry picks to one 'merge-base' call
      per merge, per branch which used cherry picking.
      Signed-off-by: Sam Vilain <sam@vilain.net>
      Acked-by: Eric Wong <normalperson@yhbt.net>

That being said, you have clearly addressed the points I raised in my earlier mail. The loop, taken by itself, now throws out elements of the $new_parents list that are ancestors of another element which is a sane thing to do if you're building a merge.

So with the catch that I only looked at the immediate neighbourhood in the code:

  Acked-by: Thomas Rast <trast@student.ethz.ch>
-- 
Thomas Rast
trast@{inf,student}.ethz.ch
Eric Wong· Feb 26, 2010, 09:50 UTC · re: Tuomas Suutari · lore

Re: git-svn detects some merges incorrectly from svn:mergeinfo

Tuomas Suutari <tuomas.suutari@gmail.com> wrote:
Show 13 quoted lines
> Hi,
> 
> Now that git-svn detects merges from svn:mergeinfo, I thought it's
> time to re-import some of my SVN repos with git-svn. Detecting of the
> merges worked mostly well, but when inspecting the imported history
> with gitk, I found some incorrectly detected merges.
> 
> This patch series adds a test case and a fix for the case.
> 
> I was a bit uncertain if the fix should go to parents_exclude function
> or to "cater for merges which merge commits from multiple branches"
> section of find_extra_svn_parents function. I chose the latter and at
> least it does the trick.
Thanks Tuomas and Sam+Thomas for the feedback.

I've pushed this series out to git://git.bogomips.org/git-svn along with Josh's speedup.

Tuomas Suutari (3):
      t9151: Fix a few commits in the SVN dump
      t9151: Add two new svn:mergeinfo test cases
      git-svn: Fix discarding of extra parents from svn:mergeinfo
josh robb (1):
      git svn: delay importing SVN::Base until it is needed
-- 
Eric Wong

← back to recent threads