annotate tests/test-convert-hg-svn.t @ 23702:c48924787eaa

filectx.parents: enforce changeid of parent to be in own changectx ancestors Because of the way filenodes are computed, you can have multiple changesets "introducing" the same file revision. For example, in the changeset graph below, changeset 2 and 3 both change a file -to- and -from- the same content. o 3: content = new | | o 2: content = new |/ o 1: content = old In such cases, the file revision is create once, when 2 is added, and just reused for 3. So the file change in '3' (from "old" to "new)" has no linkrev pointing to it). We'll call this situation "linkrev-shadowing". As the linkrev is used for optimization purposes when walking a file history, the linkrev-shadowing results in an unexpected jump to another branch during such a walk.. This leads to multiple bugs with log, annotate and rename detection. One element to fix such bugs is to ensure that walking the file history sticks on the same topology as the changeset's history. For this purpose, we extend the logic in 'basefilectx.parents' so that it always defines the proper changeset to associate the parent file revision with. This "proper" changeset has to be an ancestor of the changeset associated with the child file revision. This logic is performed in the '_adjustlinkrev' function. This function is given the starting changeset and all the information regarding the parent file revision. If the linkrev for the file revision is an ancestor of the starting changeset, the linkrev is valid and will be used. If it is not, we detected a topological jump caused by linkrev shadowing, we are going to walk the ancestors of the starting changeset until we find one setting the file to the revision we are trying to create. The performance impact appears acceptable: - We are walking the changelog once for each filelog traversal (as there should be no overlap between searches), - changelog traversal itself is fairly cheap, compared to what is likely going to be perform on the result on the filelog traversal, - We only touch the manifest for ancestors touching the file, And such changesets are likely to be the one introducing the file. (except in pathological cases involving merge), - We use manifest diff instead of full manifest unpacking to check manifest content, so it does not involve applying multiple diffs in most case. - linkrev shadowing is not the common case. Tests for fixed issues in log, annotate and rename detection have been added. But this changeset does not solve all problems. It fixes -ancestry- computation, but if the linkrev-shadowed changesets is the starting one, we'll still get things wrong. We'll have to fix the bootstrapping of such operations in a later changeset. Also, the usage of `hg log FILE` without --follow still has issues with linkrev pointing to hidden changesets, because it relies on the `filelog` revset which implement its own traversal logic that is still to be fixed. Thanks goes to: - Matt Mackall: for nudging me in the right direction - Julien Cristau and RĂ©mi Cardona: for keep telling me linkrev bug were an evolution show stopper for 3 years. - Durham Goode: for finding a new linkrev issue every few weeks - Mads Kiilerich: for that last rename bug who raise this topic over my anoyance limit.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Tue, 23 Dec 2014 15:30:38 -0800
parents e955549cd045
children b65481675466
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22046
7a9cbb315d84 tests: replace exit 80 with #require
Matt Mackall <mpm@selenic.com>
parents: 20419
diff changeset
1 #require svn svn-bindings
5554
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2
23172
e955549cd045 tests: write hgrc of more than two lines by using shell heredoc
Yuya Nishihara <yuya@tcha.org>
parents: 22947
diff changeset
3 $ cat <<EOF >> $HGRCPATH
e955549cd045 tests: write hgrc of more than two lines by using shell heredoc
Yuya Nishihara <yuya@tcha.org>
parents: 22947
diff changeset
4 > [extensions]
e955549cd045 tests: write hgrc of more than two lines by using shell heredoc
Yuya Nishihara <yuya@tcha.org>
parents: 22947
diff changeset
5 > convert =
e955549cd045 tests: write hgrc of more than two lines by using shell heredoc
Yuya Nishihara <yuya@tcha.org>
parents: 22947
diff changeset
6 > mq =
e955549cd045 tests: write hgrc of more than two lines by using shell heredoc
Yuya Nishihara <yuya@tcha.org>
parents: 22947
diff changeset
7 > EOF
17033
0413f68da85c tests: cleanup of svn url handling
Mads Kiilerich <mads@kiilerich.com>
parents: 12527
diff changeset
8
0413f68da85c tests: cleanup of svn url handling
Mads Kiilerich <mads@kiilerich.com>
parents: 12527
diff changeset
9 $ SVNREPOPATH=`pwd`/svn-repo
0413f68da85c tests: cleanup of svn url handling
Mads Kiilerich <mads@kiilerich.com>
parents: 12527
diff changeset
10 #if windows
22947
c63a09b6b337 tests: use $PYTHON instead of hardcoding python
Augie Fackler <raf@durin42.com>
parents: 22046
diff changeset
11 $ SVNREPOURL=file:///`$PYTHON -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"`
17033
0413f68da85c tests: cleanup of svn url handling
Mads Kiilerich <mads@kiilerich.com>
parents: 12527
diff changeset
12 #else
22947
c63a09b6b337 tests: use $PYTHON instead of hardcoding python
Augie Fackler <raf@durin42.com>
parents: 22046
diff changeset
13 $ SVNREPOURL=file://`$PYTHON -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"`
17033
0413f68da85c tests: cleanup of svn url handling
Mads Kiilerich <mads@kiilerich.com>
parents: 12527
diff changeset
14 #endif
0413f68da85c tests: cleanup of svn url handling
Mads Kiilerich <mads@kiilerich.com>
parents: 12527
diff changeset
15
0413f68da85c tests: cleanup of svn url handling
Mads Kiilerich <mads@kiilerich.com>
parents: 12527
diff changeset
16 $ svnadmin create "$SVNREPOPATH"
0413f68da85c tests: cleanup of svn url handling
Mads Kiilerich <mads@kiilerich.com>
parents: 12527
diff changeset
17 $ cat > "$SVNREPOPATH"/hooks/pre-revprop-change <<EOF
12527
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
18 > #!/bin/sh
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
19 >
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
20 > REPOS="$1"
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
21 > REV="$2"
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
22 > USER="$3"
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
23 > PROPNAME="$4"
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
24 > ACTION="$5"
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
25 >
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
26 > if [ "$ACTION" = "M" -a "$PROPNAME" = "svn:log" ]; then exit 0; fi
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
27 > if [ "$ACTION" = "A" -a "$PROPNAME" = "hg:convert-branch" ]; then exit 0; fi
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
28 > if [ "$ACTION" = "A" -a "$PROPNAME" = "hg:convert-rev" ]; then exit 0; fi
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
29 >
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
30 > echo "Changing prohibited revision property" >&2
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
31 > exit 1
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
32 > EOF
17033
0413f68da85c tests: cleanup of svn url handling
Mads Kiilerich <mads@kiilerich.com>
parents: 12527
diff changeset
33 $ chmod +x "$SVNREPOPATH"/hooks/pre-revprop-change
0413f68da85c tests: cleanup of svn url handling
Mads Kiilerich <mads@kiilerich.com>
parents: 12527
diff changeset
34 $ svn co "$SVNREPOURL" "$SVNREPOPATH"-wc
12527
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
35 Checked out revision 0.
17033
0413f68da85c tests: cleanup of svn url handling
Mads Kiilerich <mads@kiilerich.com>
parents: 12527
diff changeset
36 $ cd "$SVNREPOPATH"-wc
12527
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
37 $ echo a > a
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
38 $ svn add a
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
39 A a
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
40 $ svn ci -m'added a' a
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
41 Adding a
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
42 Transmitting file data .
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
43 Committed revision 1.
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
44 $ cd ..
5554
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
45
12527
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
46 initial roundtrip
5554
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
47
17033
0413f68da85c tests: cleanup of svn url handling
Mads Kiilerich <mads@kiilerich.com>
parents: 12527
diff changeset
48 $ hg convert -s svn -d hg "$SVNREPOPATH"-wc "$SVNREPOPATH"-hg | grep -v initializing
12527
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
49 scanning source...
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
50 sorting...
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
51 converting...
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
52 0 added a
17033
0413f68da85c tests: cleanup of svn url handling
Mads Kiilerich <mads@kiilerich.com>
parents: 12527
diff changeset
53 $ hg convert -s hg -d svn "$SVNREPOPATH"-hg "$SVNREPOPATH"-wc
12527
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
54 scanning source...
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
55 sorting...
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
56 converting...
5554
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
57
12527
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
58 second roundtrip should do nothing
5554
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
59
17033
0413f68da85c tests: cleanup of svn url handling
Mads Kiilerich <mads@kiilerich.com>
parents: 12527
diff changeset
60 $ hg convert -s svn -d hg "$SVNREPOPATH"-wc "$SVNREPOPATH"-hg
12527
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
61 scanning source...
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
62 sorting...
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
63 converting...
17033
0413f68da85c tests: cleanup of svn url handling
Mads Kiilerich <mads@kiilerich.com>
parents: 12527
diff changeset
64 $ hg convert -s hg -d svn "$SVNREPOPATH"-hg "$SVNREPOPATH"-wc
12527
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
65 scanning source...
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
66 sorting...
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
67 converting...
5554
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
68
12527
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
69 new hg rev
5554
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
70
17033
0413f68da85c tests: cleanup of svn url handling
Mads Kiilerich <mads@kiilerich.com>
parents: 12527
diff changeset
71 $ hg clone "$SVNREPOPATH"-hg "$SVNREPOPATH"-work
12527
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
72 updating to branch default
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
73 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
17033
0413f68da85c tests: cleanup of svn url handling
Mads Kiilerich <mads@kiilerich.com>
parents: 12527
diff changeset
74 $ cd "$SVNREPOPATH"-work
12527
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
75 $ echo b > b
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
76 $ hg add b
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
77 $ hg ci -mb
5554
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
78
12527
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
79 adding an empty revision
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
80
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
81 $ hg qnew -m emtpy empty
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
82 $ hg qfinish -a
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
83 $ cd ..
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
84
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
85 echo hg to svn
5554
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
86
17033
0413f68da85c tests: cleanup of svn url handling
Mads Kiilerich <mads@kiilerich.com>
parents: 12527
diff changeset
87 $ hg --cwd "$SVNREPOPATH"-hg pull -q "$SVNREPOPATH"-work
0413f68da85c tests: cleanup of svn url handling
Mads Kiilerich <mads@kiilerich.com>
parents: 12527
diff changeset
88 $ hg convert -s hg -d svn "$SVNREPOPATH"-hg "$SVNREPOPATH"-wc
12527
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
89 scanning source...
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
90 sorting...
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
91 converting...
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
92 1 b
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
93 0 emtpy
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
94
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
95 svn back to hg should do nothing
5554
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
96
17033
0413f68da85c tests: cleanup of svn url handling
Mads Kiilerich <mads@kiilerich.com>
parents: 12527
diff changeset
97 $ hg convert -s svn -d hg "$SVNREPOPATH"-wc "$SVNREPOPATH"-hg
12527
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
98 scanning source...
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
99 sorting...
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
100 converting...
5554
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
101
12527
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
102 hg back to svn should do nothing
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
103
17033
0413f68da85c tests: cleanup of svn url handling
Mads Kiilerich <mads@kiilerich.com>
parents: 12527
diff changeset
104 $ hg convert -s hg -d svn "$SVNREPOPATH"-hg "$SVNREPOPATH"-wc
12527
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
105 scanning source...
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
106 sorting...
9a0528fd9172 tests: unify test-convert-hg-svn
Matt Mackall <mpm@selenic.com>
parents: 10775
diff changeset
107 converting...
20419
e61a8395c3c1 convert: make subversion revsplit more stable when meeting revisions without @
Mads Kiilerich <madski@unity3d.com>
parents: 17033
diff changeset
108
e61a8395c3c1 convert: make subversion revsplit more stable when meeting revisions without @
Mads Kiilerich <madski@unity3d.com>
parents: 17033
diff changeset
109 verify which shamap format we are storing and must be able to handle
e61a8395c3c1 convert: make subversion revsplit more stable when meeting revisions without @
Mads Kiilerich <madski@unity3d.com>
parents: 17033
diff changeset
110
e61a8395c3c1 convert: make subversion revsplit more stable when meeting revisions without @
Mads Kiilerich <madski@unity3d.com>
parents: 17033
diff changeset
111 $ cat svn-repo-hg/.hg/shamap
e61a8395c3c1 convert: make subversion revsplit more stable when meeting revisions without @
Mads Kiilerich <madski@unity3d.com>
parents: 17033
diff changeset
112 svn:????????-????-????-????-????????????@1 ???????????????????????????????????????? (glob)
e61a8395c3c1 convert: make subversion revsplit more stable when meeting revisions without @
Mads Kiilerich <madski@unity3d.com>
parents: 17033
diff changeset
113 svn:????????-????-????-????-????????????@2 ???????????????????????????????????????? (glob)
e61a8395c3c1 convert: make subversion revsplit more stable when meeting revisions without @
Mads Kiilerich <madski@unity3d.com>
parents: 17033
diff changeset
114 svn:????????-????-????-????-????????????@2 ???????????????????????????????????????? (glob)
e61a8395c3c1 convert: make subversion revsplit more stable when meeting revisions without @
Mads Kiilerich <madski@unity3d.com>
parents: 17033
diff changeset
115 $ cat svn-repo-wc/.svn/hg-shamap
e61a8395c3c1 convert: make subversion revsplit more stable when meeting revisions without @
Mads Kiilerich <madski@unity3d.com>
parents: 17033
diff changeset
116 ???????????????????????????????????????? 1 (glob)
e61a8395c3c1 convert: make subversion revsplit more stable when meeting revisions without @
Mads Kiilerich <madski@unity3d.com>
parents: 17033
diff changeset
117 ???????????????????????????????????????? svn:????????-????-????-????-????????????@2 (glob)
e61a8395c3c1 convert: make subversion revsplit more stable when meeting revisions without @
Mads Kiilerich <madski@unity3d.com>
parents: 17033
diff changeset
118 ???????????????????????????????????????? svn:????????-????-????-????-????????????@2 (glob)