comparison tests/test-wireproto-exchangev2.t @ 39654:d292328e0143

exchangev2: fetch manifest revisions Now that the server has support for retrieving manifest data, we can implement the client bits to call it. We teach the changeset fetching code to capture the manifest revisions that are encountered on incoming changesets. We then feed this into a new function which filters out known manifests and then batches up manifest data requests to the server. This is different from the previous wire protocol in a few notable ways. First, the client fetches manifest data separately and explicitly. Before, we'd ask the server for data pertaining to some changesets (via a "getbundle" command) and manifests (and files) would be sent automatically. Providing an API for looking up just manifest data separately gives clients much more flexibility for manifest management. For example, a client may choose to only fetch manifest data on demand instead of prefetching it (i.e. partial clone). Second, we send N commands to the server for manifest retrieval instead of 1. This property has a few nice side-effects. One is that the deterministic nature of the requests lends itself to server-side caching. For example, say the remote has 50,000 manifests. If the server is configured to cache responses, each time a new commit arrives, you will have a cache miss and need to regenerate all outgoing data. But if you makes N requests requesting 10,000 manifests each, a new commit will still yield cache hits on the initial, unchanged manifest batches/requests. A derived benefit from these properties is that resumable clone is conceptually simpler to implement. When making a monolithic request for all of the repository data, recovering from an interrupted clone is hard because the server was in the driver's seat and was maintaining state about all the data that needed transferred. With the client driving fetching, the client can persist the set of unfetched entities and retry/resume a fetch if something goes wrong. Or we can fetch all data N changesets at a time and slowly build up a repository. This approach is drastically easier to implement when we have server APIs exposing low-level repository primitives (such as manifests and files). We don't yet support tree manifests. But it should be possible to implement that with the existing wire protocol command. Differential Revision: https://phab.mercurial-scm.org/D4489
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 05 Sep 2018 09:09:57 -0700
parents 349482d726ee
children 039bf1eddc2e
comparison
equal deleted inserted replaced
39653:c7a7c7e844e5 39654:d292328e0143
74 add changeset 4432d83626e8 74 add changeset 4432d83626e8
75 add changeset cd2534766bec 75 add changeset cd2534766bec
76 add changeset e96ae20f4188 76 add changeset e96ae20f4188
77 add changeset caa2a465451d 77 add changeset caa2a465451d
78 checking for updated bookmarks 78 checking for updated bookmarks
79 sending 1 commands
80 sending command manifestdata: {
81 'fields': set([
82 'parents',
83 'revision'
84 ]),
85 'nodes': [
86 '\x99/Gy\x02\x9a=\xf8\xd0fm\x00\xbb\x92OicN&A',
87 '\xa9\x88\xfbCX>\x87\x1d\x1e\xd5u\x0e\xe0t\xc6\xd8@\xbb\xbf\xc8',
88 '\xec\x80NH\x8c \x88\xc25\t\x9a\x10 u\x13\xbe\xcd\xc3\xdd\xa5',
89 '\x04\\\x7f9\'\xda\x13\xe7Z\xf8\xf0\xe4\xf0HI\xe4a\xa9x\x0f',
90 '7\x9c\xb0\xc2\xe6d\\y\xdd\xc5\x9a\x1dG\'\xa9\xfb\x83\n\xeb&'
91 ],
92 'tree': ''
93 }
94 received frame(size=11; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=continuation)
95 received frame(size=922; request=1; stream=2; streamflags=; type=command-response; flags=continuation)
96 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
79 updating the branch cache 97 updating the branch cache
80 new changesets 3390ef850073:caa2a465451d (3 drafts) 98 new changesets 3390ef850073:caa2a465451d (3 drafts)
81 99
82 All changesets should have been transferred 100 All changesets should have been transferred
83 101
99 | o 1 4432d83626e8a98655f062ec1f2a43b07f7fbbb0 public 117 | o 1 4432d83626e8a98655f062ec1f2a43b07f7fbbb0 public
100 |/ 118 |/
101 o 0 3390ef850073fbc2f0dfff2244342c8e9229013a public 119 o 0 3390ef850073fbc2f0dfff2244342c8e9229013a public
102 120
103 121
122 All manifests should have been transferred
123
124 $ hg -R client-simple debugindex -m
125 rev linkrev nodeid p1 p2
126 0 0 992f4779029a 000000000000 000000000000
127 1 1 a988fb43583e 992f4779029a 000000000000
128 2 2 ec804e488c20 a988fb43583e 000000000000
129 3 3 045c7f3927da 992f4779029a 000000000000
130 4 4 379cb0c2e664 045c7f3927da 000000000000
131
104 Cloning only a specific revision works 132 Cloning only a specific revision works
105 133
106 $ hg --debug clone -U -r 4432d83626e8 http://localhost:$HGPORT client-singlehead 134 $ hg --debug clone -U -r 4432d83626e8 http://localhost:$HGPORT client-singlehead
107 using http://localhost:$HGPORT/ 135 using http://localhost:$HGPORT/
108 sending capabilities command 136 sending capabilities command
144 received frame(size=353; request=1; stream=2; streamflags=; type=command-response; flags=continuation) 172 received frame(size=353; request=1; stream=2; streamflags=; type=command-response; flags=continuation)
145 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos) 173 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
146 add changeset 3390ef850073 174 add changeset 3390ef850073
147 add changeset 4432d83626e8 175 add changeset 4432d83626e8
148 checking for updated bookmarks 176 checking for updated bookmarks
177 sending 1 commands
178 sending command manifestdata: {
179 'fields': set([
180 'parents',
181 'revision'
182 ]),
183 'nodes': [
184 '\x99/Gy\x02\x9a=\xf8\xd0fm\x00\xbb\x92OicN&A',
185 '\xa9\x88\xfbCX>\x87\x1d\x1e\xd5u\x0e\xe0t\xc6\xd8@\xbb\xbf\xc8'
186 ],
187 'tree': ''
188 }
189 received frame(size=11; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=continuation)
190 received frame(size=376; request=1; stream=2; streamflags=; type=command-response; flags=continuation)
191 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
149 updating the branch cache 192 updating the branch cache
150 new changesets 3390ef850073:4432d83626e8 193 new changesets 3390ef850073:4432d83626e8
151 194
152 $ cd client-singlehead 195 $ cd client-singlehead
153 196
154 $ hg log -G -T '{rev} {node} {phase}\n' 197 $ hg log -G -T '{rev} {node} {phase}\n'
155 o 1 4432d83626e8a98655f062ec1f2a43b07f7fbbb0 public 198 o 1 4432d83626e8a98655f062ec1f2a43b07f7fbbb0 public
156 | 199 |
157 o 0 3390ef850073fbc2f0dfff2244342c8e9229013a public 200 o 0 3390ef850073fbc2f0dfff2244342c8e9229013a public
158 201
202
203 $ hg debugindex -m
204 rev linkrev nodeid p1 p2
205 0 0 992f4779029a 000000000000 000000000000
206 1 1 a988fb43583e 992f4779029a 000000000000
159 207
160 Incremental pull works 208 Incremental pull works
161 209
162 $ hg --debug pull 210 $ hg --debug pull
163 pulling from http://localhost:$HGPORT/ 211 pulling from http://localhost:$HGPORT/
202 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos) 250 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
203 add changeset cd2534766bec 251 add changeset cd2534766bec
204 add changeset e96ae20f4188 252 add changeset e96ae20f4188
205 add changeset caa2a465451d 253 add changeset caa2a465451d
206 checking for updated bookmarks 254 checking for updated bookmarks
255 sending 1 commands
256 sending command manifestdata: {
257 'fields': set([
258 'parents',
259 'revision'
260 ]),
261 'nodes': [
262 '\xec\x80NH\x8c \x88\xc25\t\x9a\x10 u\x13\xbe\xcd\xc3\xdd\xa5',
263 '\x04\\\x7f9\'\xda\x13\xe7Z\xf8\xf0\xe4\xf0HI\xe4a\xa9x\x0f',
264 '7\x9c\xb0\xc2\xe6d\\y\xdd\xc5\x9a\x1dG\'\xa9\xfb\x83\n\xeb&'
265 ],
266 'tree': ''
267 }
268 received frame(size=11; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=continuation)
269 received frame(size=559; request=1; stream=2; streamflags=; type=command-response; flags=continuation)
270 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
207 updating the branch cache 271 updating the branch cache
208 new changesets cd2534766bec:caa2a465451d (3 drafts) 272 new changesets cd2534766bec:caa2a465451d (3 drafts)
209 (run 'hg update' to get a working copy) 273 (run 'hg update' to get a working copy)
210 274
211 $ hg log -G -T '{rev} {node} {phase}\n' 275 $ hg log -G -T '{rev} {node} {phase}\n'
218 | o 1 4432d83626e8a98655f062ec1f2a43b07f7fbbb0 public 282 | o 1 4432d83626e8a98655f062ec1f2a43b07f7fbbb0 public
219 |/ 283 |/
220 o 0 3390ef850073fbc2f0dfff2244342c8e9229013a public 284 o 0 3390ef850073fbc2f0dfff2244342c8e9229013a public
221 285
222 286
287 $ hg debugindex -m
288 rev linkrev nodeid p1 p2
289 0 0 992f4779029a 000000000000 000000000000
290 1 1 a988fb43583e 992f4779029a 000000000000
291 2 2 ec804e488c20 a988fb43583e 000000000000
292 3 3 045c7f3927da 992f4779029a 000000000000
293 4 4 379cb0c2e664 045c7f3927da 000000000000
294
223 Phase-only update works 295 Phase-only update works
224 296
225 $ hg -R ../server-simple phase --public -r caa2a465451dd 297 $ hg -R ../server-simple phase --public -r caa2a465451dd
226 $ hg --debug pull 298 $ hg --debug pull
227 pulling from http://localhost:$HGPORT/ 299 pulling from http://localhost:$HGPORT/
329 add changeset e96ae20f4188 401 add changeset e96ae20f4188
330 add changeset caa2a465451d 402 add changeset caa2a465451d
331 checking for updated bookmarks 403 checking for updated bookmarks
332 adding remote bookmark book-1 404 adding remote bookmark book-1
333 adding remote bookmark book-2 405 adding remote bookmark book-2
406 sending 1 commands
407 sending command manifestdata: {
408 'fields': set([
409 'parents',
410 'revision'
411 ]),
412 'nodes': [
413 '\x99/Gy\x02\x9a=\xf8\xd0fm\x00\xbb\x92OicN&A',
414 '\xa9\x88\xfbCX>\x87\x1d\x1e\xd5u\x0e\xe0t\xc6\xd8@\xbb\xbf\xc8',
415 '\xec\x80NH\x8c \x88\xc25\t\x9a\x10 u\x13\xbe\xcd\xc3\xdd\xa5',
416 '\x04\\\x7f9\'\xda\x13\xe7Z\xf8\xf0\xe4\xf0HI\xe4a\xa9x\x0f',
417 '7\x9c\xb0\xc2\xe6d\\y\xdd\xc5\x9a\x1dG\'\xa9\xfb\x83\n\xeb&'
418 ],
419 'tree': ''
420 }
421 received frame(size=11; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=continuation)
422 received frame(size=922; request=1; stream=2; streamflags=; type=command-response; flags=continuation)
423 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
334 updating the branch cache 424 updating the branch cache
335 new changesets 3390ef850073:caa2a465451d (1 drafts) 425 new changesets 3390ef850073:caa2a465451d (1 drafts)
336 426
337 $ hg -R client-bookmarks bookmarks 427 $ hg -R client-bookmarks bookmarks
338 book-1 0:3390ef850073 428 book-1 0:3390ef850073