##// END OF EJS Templates
compat: normalise path before comparison in revlog splitting test...
Raphaël Gomès -
r48361:8e929591 default
parent child Browse files
Show More
@@ -1,184 +1,183 b''
1 1 Test correctness of revlog inline -> non-inline transition
2 2 ----------------------------------------------------------
3 3
4 4 Helper extension to intercept renames.
5 5
6 6 $ cat > $TESTTMP/intercept_rename.py << EOF
7 7 > import os
8 8 > import sys
9 9 > from mercurial import extensions, util
10 10 >
11 11 > def extsetup(ui):
12 12 > def close(orig, *args, **kwargs):
13 > path = args[0]._atomictempfile__name
13 > path = util.normpath(args[0]._atomictempfile__name)
14 14 > if path.endswith(b'/.hg/store/data/file.i'):
15 15 > os._exit(80)
16 16 > return orig(*args, **kwargs)
17 17 > extensions.wrapfunction(util.atomictempfile, 'close', close)
18 18 > EOF
19 19
20
21 20 Test offset computation to correctly factor in the index entries themselve.
22 21 Also test that the new data size has the correct size if the transaction is aborted
23 22 after the index has been replaced.
24 23
25 24 Test repo has one small, one moderate and one big change. The clone has
26 25 the small and moderate change and will transition to non-inline storage when
27 26 adding the big change.
28 27
29 28 $ hg init troffset-computation --config format.revlog-compression=none
30 29 $ cd troffset-computation
31 30 $ printf '%20d' '1' > file
32 31 $ hg commit -Aqm_
33 32 $ printf '%1024d' '1' > file
34 33 $ hg commit -Aqm_
35 34 $ dd if=/dev/zero of=file bs=1k count=128 > /dev/null 2>&1
36 35 $ hg commit -Aqm_
37 36 $ cd ..
38 37
39 38 $ hg clone -r 1 troffset-computation troffset-computation-copy --config format.revlog-compression=none -q
40 39 $ cd troffset-computation-copy
41 40
42 41 Reference size:
43 42
44 43 $ f -s .hg/store/data/file*
45 44 .hg/store/data/file.i: size=1174
46 45
47 46 $ cat > .hg/hgrc <<EOF
48 47 > [hooks]
49 48 > pretxnchangegroup = python:$TESTDIR/helper-killhook.py:killme
50 49 > EOF
51 50 #if chg
52 51 $ hg pull ../troffset-computation
53 52 pulling from ../troffset-computation
54 53 [255]
55 54 #else
56 55 $ hg pull ../troffset-computation
57 56 pulling from ../troffset-computation
58 57 [80]
59 58 #endif
60 59 $ cat .hg/store/journal | tr -s '\000' ' ' | grep data/file | tail -1
61 60 data/file.i 128
62 61
63 62 The first file.i entry should match the size above.
64 63 The first file.d entry is the temporary record during the split,
65 64 the second entry after the split happened. The sum of the second file.d
66 65 and the second file.i entry should match the first file.i entry.
67 66
68 67 $ cat .hg/store/journal | tr -s '\000' ' ' | grep data/file
69 68 data/file.i 1174
70 69 data/file.d 0
71 70 data/file.d 1046
72 71 data/file.i 128
73 72 $ hg recover
74 73 rolling back interrupted transaction
75 74 (verify step skipped, run `hg verify` to check your repository content)
76 75 $ f -s .hg/store/data/file*
77 76 .hg/store/data/file.d: size=1046
78 77 .hg/store/data/file.i: size=128
79 78 $ hg tip
80 79 changeset: 1:3ce491143aec
81 80 tag: tip
82 81 user: test
83 82 date: Thu Jan 01 00:00:00 1970 +0000
84 83 summary: _
85 84
86 85 $ hg verify
87 86 checking changesets
88 87 checking manifests
89 88 crosschecking files in changesets and manifests
90 89 checking files
91 90 warning: revlog 'data/file.d' not in fncache!
92 91 checked 2 changesets with 2 changes to 1 files
93 92 1 warnings encountered!
94 93 hint: run "hg debugrebuildfncache" to recover from corrupt fncache
95 94 $ cd ..
96 95
97 96
98 97 Now retry the procedure but intercept the rename of the index and check that
99 98 the journal does not contain the new index size. This demonstrates the edge case
100 99 where the data file is left as garbage.
101 100
102 101 $ hg clone -r 1 troffset-computation troffset-computation-copy2 --config format.revlog-compression=none -q
103 102 $ cd troffset-computation-copy2
104 103 $ cat > .hg/hgrc <<EOF
105 104 > [extensions]
106 105 > intercept_rename = $TESTTMP/intercept_rename.py
107 106 > [hooks]
108 107 > pretxnchangegroup = python:$TESTDIR/helper-killhook.py:killme
109 108 > EOF
110 109 #if chg
111 110 $ hg pull ../troffset-computation
112 111 pulling from ../troffset-computation
113 112 [255]
114 113 #else
115 114 $ hg pull ../troffset-computation
116 115 pulling from ../troffset-computation
117 116 [80]
118 117 #endif
119 118 $ cat .hg/store/journal | tr -s '\000' ' ' | grep data/file
120 119 data/file.i 1174
121 120 data/file.d 0
122 121 data/file.d 1046
123 122
124 123 $ hg recover
125 124 rolling back interrupted transaction
126 125 (verify step skipped, run `hg verify` to check your repository content)
127 126 $ f -s .hg/store/data/file*
128 127 .hg/store/data/file.d: size=1046
129 128 .hg/store/data/file.i: size=1174
130 129 $ hg tip
131 130 changeset: 1:3ce491143aec
132 131 tag: tip
133 132 user: test
134 133 date: Thu Jan 01 00:00:00 1970 +0000
135 134 summary: _
136 135
137 136 $ hg verify
138 137 checking changesets
139 138 checking manifests
140 139 crosschecking files in changesets and manifests
141 140 checking files
142 141 checked 2 changesets with 2 changes to 1 files
143 142 $ cd ..
144 143
145 144
146 145 Repeat the original test but let hg rollback the transaction.
147 146
148 147 $ hg clone -r 1 troffset-computation troffset-computation-copy-rb --config format.revlog-compression=none -q
149 148 $ cd troffset-computation-copy-rb
150 149 $ cat > .hg/hgrc <<EOF
151 150 > [hooks]
152 151 > pretxnchangegroup = false
153 152 > EOF
154 153 $ hg pull ../troffset-computation
155 154 pulling from ../troffset-computation
156 155 searching for changes
157 156 adding changesets
158 157 adding manifests
159 158 adding file changes
160 159 transaction abort!
161 160 rollback completed
162 161 abort: pretxnchangegroup hook exited with status 1
163 162 [40]
164 163 $ f -s .hg/store/data/file*
165 164 .hg/store/data/file.d: size=1046
166 165 .hg/store/data/file.i: size=128
167 166 $ hg tip
168 167 changeset: 1:3ce491143aec
169 168 tag: tip
170 169 user: test
171 170 date: Thu Jan 01 00:00:00 1970 +0000
172 171 summary: _
173 172
174 173 $ hg verify
175 174 checking changesets
176 175 checking manifests
177 176 crosschecking files in changesets and manifests
178 177 checking files
179 178 warning: revlog 'data/file.d' not in fncache!
180 179 checked 2 changesets with 2 changes to 1 files
181 180 1 warnings encountered!
182 181 hint: run "hg debugrebuildfncache" to recover from corrupt fncache
183 182 $ cd ..
184 183
General Comments 0
You need to be logged in to leave comments. Login now