Show More
@@ -1,271 +1,280 | |||
|
1 | 1 | #require no-windows |
|
2 | 2 | |
|
3 | 3 | $ . "$TESTDIR/remotefilelog-library.sh" |
|
4 | 4 | |
|
5 | 5 | $ hg init master |
|
6 | 6 | $ cd master |
|
7 | 7 | $ cat >> .hg/hgrc <<EOF |
|
8 | 8 | > [remotefilelog] |
|
9 | 9 | > server=True |
|
10 | 10 | > EOF |
|
11 | 11 | $ echo x > x |
|
12 | 12 | $ echo z > z |
|
13 | 13 | $ hg commit -qAm x |
|
14 | 14 | $ echo x2 > x |
|
15 | 15 | $ echo y > y |
|
16 | 16 | $ hg commit -qAm y |
|
17 | 17 | $ hg bookmark foo |
|
18 | 18 | |
|
19 | 19 | $ cd .. |
|
20 | 20 | |
|
21 | 21 | # prefetch a revision |
|
22 | 22 | |
|
23 | 23 | $ hgcloneshallow ssh://user@dummy/master shallow --noupdate |
|
24 | 24 | streaming all changes |
|
25 | 25 | 2 files to transfer, 528 bytes of data |
|
26 | 26 | transferred 528 bytes in * seconds (*/sec) (glob) |
|
27 | 27 | searching for changes |
|
28 | 28 | no changes found |
|
29 | 29 | $ cd shallow |
|
30 | 30 | |
|
31 | 31 | $ hg prefetch -r 0 |
|
32 | 32 | 2 files fetched over 1 fetches - (2 misses, 0.00% hit ratio) over *s (glob) |
|
33 | 33 | |
|
34 | 34 | $ hg cat -r 0 x |
|
35 | 35 | x |
|
36 | 36 | |
|
37 | 37 | # prefetch with base |
|
38 | 38 | |
|
39 | 39 | $ clearcache |
|
40 | 40 | $ hg prefetch -r 0::1 -b 0 |
|
41 | 41 | 2 files fetched over 1 fetches - (2 misses, 0.00% hit ratio) over *s (glob) |
|
42 | 42 | |
|
43 | 43 | $ hg cat -r 1 x |
|
44 | 44 | x2 |
|
45 | 45 | $ hg cat -r 1 y |
|
46 | 46 | y |
|
47 | 47 | |
|
48 | 48 | $ hg cat -r 0 x |
|
49 | 49 | x |
|
50 | 50 | 1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob) |
|
51 | 51 | |
|
52 | 52 | $ hg cat -r 0 z |
|
53 | 53 | z |
|
54 | 54 | 1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob) |
|
55 | 55 | |
|
56 | 56 | $ hg prefetch -r 0::1 --base 0 |
|
57 | 57 | $ hg prefetch -r 0::1 -b 1 |
|
58 | 58 | $ hg prefetch -r 0::1 |
|
59 | 59 | |
|
60 | 60 | # prefetch a range of revisions |
|
61 | 61 | |
|
62 | 62 | $ clearcache |
|
63 | 63 | $ hg prefetch -r 0::1 |
|
64 | 64 | 4 files fetched over 1 fetches - (4 misses, 0.00% hit ratio) over *s (glob) |
|
65 | 65 | |
|
66 | 66 | $ hg cat -r 0 x |
|
67 | 67 | x |
|
68 | 68 | $ hg cat -r 1 x |
|
69 | 69 | x2 |
|
70 | 70 | |
|
71 | 71 | # prefetch certain files |
|
72 | 72 | |
|
73 | 73 | $ clearcache |
|
74 | 74 | $ hg prefetch -r 1 x |
|
75 | 75 | 1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob) |
|
76 | 76 | |
|
77 | 77 | $ hg cat -r 1 x |
|
78 | 78 | x2 |
|
79 | 79 | |
|
80 | 80 | $ hg cat -r 1 y |
|
81 | 81 | y |
|
82 | 82 | 1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob) |
|
83 | 83 | |
|
84 | 84 | # prefetch on pull when configured |
|
85 | 85 | |
|
86 | 86 | $ printf "[remotefilelog]\npullprefetch=bookmark()\n" >> .hg/hgrc |
|
87 | 87 | $ hg strip tip |
|
88 | 88 | saved backup bundle to $TESTTMP/shallow/.hg/strip-backup/109c3a557a73-3f43405e-backup.hg (glob) |
|
89 | 89 | |
|
90 | 90 | $ clearcache |
|
91 | 91 | $ hg pull |
|
92 | 92 | pulling from ssh://user@dummy/master |
|
93 | 93 | searching for changes |
|
94 | 94 | adding changesets |
|
95 | 95 | adding manifests |
|
96 | 96 | adding file changes |
|
97 | 97 | updating bookmark foo |
|
98 | 98 | added 1 changesets with 0 changes to 0 files |
|
99 | 99 | new changesets 109c3a557a73 |
|
100 | 100 | (run 'hg update' to get a working copy) |
|
101 | 101 | prefetching file contents |
|
102 | 102 | 3 files fetched over 1 fetches - (3 misses, 0.00% hit ratio) over *s (glob) |
|
103 | 103 | |
|
104 | 104 | $ hg up tip |
|
105 | 105 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
106 | 106 | |
|
107 | 107 | # prefetch only fetches changes not in working copy |
|
108 | 108 | |
|
109 | 109 | $ hg strip tip |
|
110 | 110 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
111 | 111 | saved backup bundle to $TESTTMP/shallow/.hg/strip-backup/109c3a557a73-3f43405e-backup.hg (glob) |
|
112 | 112 | 1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob) |
|
113 | 113 | $ clearcache |
|
114 | 114 | |
|
115 | 115 | $ hg pull |
|
116 | 116 | pulling from ssh://user@dummy/master |
|
117 | 117 | searching for changes |
|
118 | 118 | adding changesets |
|
119 | 119 | adding manifests |
|
120 | 120 | adding file changes |
|
121 | 121 | updating bookmark foo |
|
122 | 122 | added 1 changesets with 0 changes to 0 files |
|
123 | 123 | new changesets 109c3a557a73 |
|
124 | 124 | (run 'hg update' to get a working copy) |
|
125 | 125 | prefetching file contents |
|
126 | 126 | 2 files fetched over 1 fetches - (2 misses, 0.00% hit ratio) over *s (glob) |
|
127 | 127 | |
|
128 | 128 | # Make some local commits that produce the same file versions as are on the |
|
129 | 129 | # server. To simulate a situation where we have local commits that were somehow |
|
130 | 130 | # pushed, and we will soon pull. |
|
131 | 131 | |
|
132 | 132 | $ hg prefetch -r 'all()' |
|
133 | 133 | 2 files fetched over 1 fetches - (2 misses, 0.00% hit ratio) over *s (glob) |
|
134 | 134 | $ hg strip -q -r 0 |
|
135 | 135 | $ echo x > x |
|
136 | 136 | $ echo z > z |
|
137 | 137 | $ hg commit -qAm x |
|
138 | 138 | $ echo x2 > x |
|
139 | 139 | $ echo y > y |
|
140 | 140 | $ hg commit -qAm y |
|
141 | 141 | |
|
142 | 142 | # prefetch server versions, even if local versions are available |
|
143 | 143 | |
|
144 | 144 | $ clearcache |
|
145 | 145 | $ hg strip -q tip |
|
146 | 146 | $ hg pull |
|
147 | 147 | pulling from ssh://user@dummy/master |
|
148 | 148 | searching for changes |
|
149 | 149 | adding changesets |
|
150 | 150 | adding manifests |
|
151 | 151 | adding file changes |
|
152 | 152 | updating bookmark foo |
|
153 | 153 | added 1 changesets with 0 changes to 0 files |
|
154 | 154 | new changesets 109c3a557a73 |
|
155 | 155 | 1 local changesets published (?) |
|
156 | 156 | (run 'hg update' to get a working copy) |
|
157 | 157 | prefetching file contents |
|
158 | 158 | 2 files fetched over 1 fetches - (2 misses, 0.00% hit ratio) over *s (glob) |
|
159 | 159 | |
|
160 | 160 | $ cd .. |
|
161 | 161 | |
|
162 | 162 | # Prefetch unknown files during checkout |
|
163 | 163 | |
|
164 | 164 | $ hgcloneshallow ssh://user@dummy/master shallow2 |
|
165 | 165 | streaming all changes |
|
166 | 166 | 2 files to transfer, 528 bytes of data |
|
167 | 167 | transferred 528 bytes in * seconds * (glob) |
|
168 | 168 | searching for changes |
|
169 | 169 | no changes found |
|
170 | 170 | updating to branch default |
|
171 | 171 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
172 | 172 | 1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over * (glob) |
|
173 | 173 | $ cd shallow2 |
|
174 | 174 | $ hg up -q null |
|
175 | 175 | $ echo x > x |
|
176 | 176 | $ echo y > y |
|
177 | 177 | $ echo z > z |
|
178 | 178 | $ clearcache |
|
179 | 179 | $ hg up tip |
|
180 | 180 | x: untracked file differs |
|
181 | 181 | 3 files fetched over 1 fetches - (3 misses, 0.00% hit ratio) over * (glob) |
|
182 | 182 | abort: untracked files in working directory differ from files in requested revision |
|
183 | 183 | [255] |
|
184 | 184 | $ hg revert --all |
|
185 | 185 | |
|
186 | 186 | # Test batch fetching of lookup files during hg status |
|
187 | 187 | $ hg up --clean tip |
|
188 | 188 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
189 | 189 | $ hg debugrebuilddirstate |
|
190 | 190 | $ clearcache |
|
191 | 191 | $ hg status |
|
192 | 192 | 3 files fetched over 1 fetches - (3 misses, 0.00% hit ratio) over * (glob) |
|
193 | 193 | |
|
194 | 194 | # Prefetch during addrename detection |
|
195 | 195 | $ hg up -q --clean tip |
|
196 | 196 | $ hg revert --all |
|
197 | 197 | $ mv x x2 |
|
198 | 198 | $ mv y y2 |
|
199 | 199 | $ mv z z2 |
|
200 | 200 | $ echo a > a |
|
201 | 201 | $ hg add a |
|
202 | 202 | $ rm a |
|
203 | 203 | $ clearcache |
|
204 | 204 | $ hg addremove -s 50 > /dev/null |
|
205 | 205 | 3 files fetched over 1 fetches - (3 misses, 0.00% hit ratio) over * (glob) |
|
206 | 206 | $ hg revert --all |
|
207 | 207 | forgetting x2 |
|
208 | 208 | forgetting y2 |
|
209 | 209 | forgetting z2 |
|
210 | 210 | undeleting x |
|
211 | 211 | undeleting y |
|
212 | 212 | undeleting z |
|
213 | 213 | |
|
214 | 214 | |
|
215 | 215 | # Revert across double renames. Note: the scary "abort", error is because |
|
216 | 216 | # https://bz.mercurial-scm.org/5419 . |
|
217 | 217 | |
|
218 | 218 | $ cd ../master |
|
219 | 219 | $ hg mv z z2 |
|
220 | 220 | $ hg commit -m 'move z -> z2' |
|
221 | 221 | $ cd ../shallow2 |
|
222 | 222 | $ hg pull -q |
|
223 | 223 | $ clearcache |
|
224 | 224 | $ hg mv y y2 |
|
225 | 225 | y2: not overwriting - file exists |
|
226 | 226 | ('hg rename --after' to record the rename) |
|
227 | 227 | [1] |
|
228 | 228 | $ hg mv x x2 |
|
229 | 229 | x2: not overwriting - file exists |
|
230 | 230 | ('hg rename --after' to record the rename) |
|
231 | 231 | [1] |
|
232 | 232 | $ hg mv z2 z3 |
|
233 | 233 | z2: not copying - file is not managed |
|
234 | 234 | abort: no files to copy |
|
235 | 235 | [255] |
|
236 | $ find $CACHEDIR -type f | sort | |
|
237 | .. The following output line about files fetches is globed because it is | |
|
238 | .. flaky, the core the test is checked when checking the cache dir, so | |
|
239 | .. hopefully this flakyness is not hiding any actual bug. | |
|
236 | 240 | $ hg revert -a -r 1 || true |
|
237 |
|
|
|
241 | ? files fetched over 1 fetches - (? misses, 0.00% hit ratio) over * (glob) | |
|
238 | 242 | abort: z2@109c3a557a73: not found in manifest! (?) |
|
243 | $ find $CACHEDIR -type f | sort | |
|
244 | $TESTTMP/hgcache/master/11/f6ad8ec52a2984abaafd7c3b516503785c2072/ef95c5376f34698742fe34f315fd82136f8f68c0 | |
|
245 | $TESTTMP/hgcache/master/39/5df8f7c51f007019cb30201c49e884b46b92fa/69a1b67522704ec122181c0890bd16e9d3e7516a | |
|
246 | $TESTTMP/hgcache/master/95/cb0bfd2977c761298d9624e4b4d4c72a39974a/076f5e2225b3ff0400b98c92aa6cdf403ee24cca | |
|
247 | $TESTTMP/hgcache/repos | |
|
239 | 248 | |
|
240 | 249 | # warning when we have excess remotefilelog fetching |
|
241 | 250 | |
|
242 | 251 | $ cat > repeated_fetch.py << EOF |
|
243 | 252 | > import binascii |
|
244 | 253 | > from mercurial import extensions, registrar |
|
245 | 254 | > cmdtable = {} |
|
246 | 255 | > command = registrar.command(cmdtable) |
|
247 | 256 | > @command(b'repeated-fetch', [], b'', inferrepo=True) |
|
248 | 257 | > def repeated_fetch(ui, repo, *args, **opts): |
|
249 | 258 | > for i in range(20): |
|
250 | 259 | > try: |
|
251 | 260 | > hexid = (b'%02x' % (i + 1)) * 20 |
|
252 | 261 | > repo.fileservice.prefetch([(b'somefile.txt', hexid)]) |
|
253 | 262 | > except Exception: |
|
254 | 263 | > pass |
|
255 | 264 | > EOF |
|
256 | 265 | |
|
257 | 266 | We should only output to the user once. We're ignoring most of the output |
|
258 | 267 | because we're not actually fetching anything real here, all the hashes are |
|
259 | 268 | bogus, so it's just going to be errors and a final summary of all the misses. |
|
260 | 269 | $ hg --config extensions.repeated_fetch=repeated_fetch.py \ |
|
261 | 270 | > --config remotefilelog.fetchwarning="fetch warning!" \ |
|
262 | 271 | > --config extensions.blackbox= \ |
|
263 | 272 | > repeated-fetch 2>&1 | grep 'fetch warning' |
|
264 | 273 | fetch warning! |
|
265 | 274 | |
|
266 | 275 | We should output to blackbox three times, with a stack trace on each (though |
|
267 | 276 | that isn't tested here). |
|
268 | 277 | $ grep 'excess remotefilelog fetching' .hg/blackbox.log |
|
269 | 278 | .* excess remotefilelog fetching: (re) |
|
270 | 279 | .* excess remotefilelog fetching: (re) |
|
271 | 280 | .* excess remotefilelog fetching: (re) |
General Comments 0
You need to be logged in to leave comments.
Login now