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