##// END OF EJS Templates
exchangev2: use filesdata...
Gregory Szorc -
r40215:b843356d default
parent child Browse files
Show More
@@ -64,7 +64,8 b' def pull(pullop):'
64 # Find all file nodes referenced by added manifests and fetch those
64 # Find all file nodes referenced by added manifests and fetch those
65 # revisions.
65 # revisions.
66 fnodes = _derivefilesfrommanifests(repo, manres['added'])
66 fnodes = _derivefilesfrommanifests(repo, manres['added'])
67 _fetchfiles(repo, tr, remote, fnodes, manres['linkrevs'])
67 _fetchfilesfromcsets(repo, tr, remote, fnodes, csetres['added'],
68 manres['linkrevs'])
68
69
69 def _pullchangesetdiscovery(repo, remote, heads, abortwhenunrelated=True):
70 def _pullchangesetdiscovery(repo, remote, heads, abortwhenunrelated=True):
70 """Determine which changesets need to be pulled."""
71 """Determine which changesets need to be pulled."""
@@ -346,6 +347,7 b' def _derivefilesfrommanifests(repo, mani'
346 return fnodes
347 return fnodes
347
348
348 def _fetchfiles(repo, tr, remote, fnodes, linkrevs):
349 def _fetchfiles(repo, tr, remote, fnodes, linkrevs):
350 """Fetch file data from explicit file revisions."""
349 def iterrevisions(objs, progress):
351 def iterrevisions(objs, progress):
350 for filerevision in objs:
352 for filerevision in objs:
351 node = filerevision[b'node']
353 node = filerevision[b'node']
@@ -418,3 +420,84 b' def _fetchfiles(repo, tr, remote, fnodes'
418 iterrevisions(objs, progress),
420 iterrevisions(objs, progress),
419 locallinkrevs[path].__getitem__,
421 locallinkrevs[path].__getitem__,
420 weakref.proxy(tr))
422 weakref.proxy(tr))
423
424 def _fetchfilesfromcsets(repo, tr, remote, fnodes, csets, manlinkrevs):
425 """Fetch file data from explicit changeset revisions."""
426
427 def iterrevisions(objs, remaining, progress):
428 while remaining:
429 filerevision = next(objs)
430
431 node = filerevision[b'node']
432
433 extrafields = {}
434
435 for field, size in filerevision.get(b'fieldsfollowing', []):
436 extrafields[field] = next(objs)
437
438 if b'delta' in extrafields:
439 basenode = filerevision[b'deltabasenode']
440 delta = extrafields[b'delta']
441 elif b'revision' in extrafields:
442 basenode = nullid
443 revision = extrafields[b'revision']
444 delta = mdiff.trivialdiffheader(len(revision)) + revision
445 else:
446 continue
447
448 yield (
449 node,
450 filerevision[b'parents'][0],
451 filerevision[b'parents'][1],
452 node,
453 basenode,
454 delta,
455 # Flags not yet supported.
456 0,
457 )
458
459 progress.increment()
460 remaining -= 1
461
462 progress = repo.ui.makeprogress(
463 _('files'), unit=_('chunks'),
464 total=sum(len(v) for v in fnodes.itervalues()))
465
466 commandmeta = remote.apidescriptor[b'commands'][b'filesdata']
467 batchsize = commandmeta.get(b'recommendedbatchsize', 50000)
468
469 for i in pycompat.xrange(0, len(csets), batchsize):
470 batch = [x for x in csets[i:i + batchsize]]
471 if not batch:
472 continue
473
474 with remote.commandexecutor() as e:
475 args = {
476 b'revisions': [{
477 b'type': b'changesetexplicit',
478 b'nodes': batch,
479 }],
480 b'fields': {b'parents', b'revision'},
481 b'haveparents': True,
482 }
483
484 objs = e.callcommand(b'filesdata', args).result()
485
486 # First object is an overall header.
487 overall = next(objs)
488
489 # We have overall['totalpaths'] segments.
490 for i in pycompat.xrange(overall[b'totalpaths']):
491 header = next(objs)
492
493 path = header[b'path']
494 store = repo.file(path)
495
496 linkrevs = {
497 fnode: manlinkrevs[mnode]
498 for fnode, mnode in fnodes[path].iteritems()}
499
500 store.addgroup(iterrevisions(objs, header[b'totalitems'],
501 progress),
502 linkrevs.__getitem__,
503 weakref.proxy(tr))
@@ -101,40 +101,30 b' Test basic clone'
101 received frame(size=11; request=1; stream=2; streamflags=encoded; type=command-response; flags=continuation)
101 received frame(size=11; request=1; stream=2; streamflags=encoded; type=command-response; flags=continuation)
102 received frame(size=992; request=1; stream=2; streamflags=encoded; type=command-response; flags=continuation)
102 received frame(size=992; request=1; stream=2; streamflags=encoded; type=command-response; flags=continuation)
103 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
103 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
104 sending 2 commands
104 sending 1 commands
105 sending command filedata: {
105 sending command filesdata: {
106 'fields': set([
106 'fields': set([
107 'parents',
107 'parents',
108 'revision'
108 'revision'
109 ]),
109 ]),
110 'haveparents': True,
110 'haveparents': True,
111 'revisions': [
112 {
111 'nodes': [
113 'nodes': [
112 '+N\xb0s\x19\xbf\xa0w\xa4\n/\x04\x916Y\xae\xf0\xdaB\xda',
114 '3\x90\xef\x85\x00s\xfb\xc2\xf0\xdf\xff"D4,\x8e\x92)\x01:',
113 '\x9a8\x12)\x97\xb3\xac\x97\xbe*\x9a\xa2\xe5V\x83\x83A\xfd\xf2\xcc',
115 'D2\xd86&\xe8\xa9\x86U\xf0b\xec\x1f*C\xb0\x7f\x7f\xbb\xb0',
114 '\xc2\xa2\x05\xc8\xb2\xad\xe2J\xf2`b\xe5<\xd5\xbc8\x01\xd6`\xda'
116 '\xcd%4vk\xec\xe18\xc7\xc1\xaf\xdch%0/\x0fb\xd8\x1f',
117 '\xe9j\xe2\x0fA\x88H{\x9a\xe4\xef9A\xc2|\x81\x141F\xe5',
118 '\xca\xa2\xa4eE\x1d\xd1\xfa\xcd\xa0\xf5\xb1#\x12\xc3UXA\x88\xa1'
115 ],
119 ],
116 'path': 'a'
120 'type': 'changesetexplicit'
117 }
121 }
118 sending command filedata: {
122 ]
119 'fields': set([
120 'parents',
121 'revision'
122 ]),
123 'haveparents': True,
124 'nodes': [
125 '\x81\x9e%\x8d1\xa5\xe1`f)\xf3e\xbb\x90*\x1b!\xeeB\x16',
126 '\xb1zk\xd3g=\x9a\xb8\xce\xd5\x81\xa2\t\xf6/=\xa5\xccEx',
127 '\xc5\xb1\xf9\xd3n\x1c\xc18\xbf\xb6\xef\xb3\xde\xb7]\x8c\xcad\x94\xc3'
128 ],
129 'path': 'b'
130 }
123 }
131 received frame(size=9; request=1; stream=2; streamflags=stream-begin; type=stream-settings; flags=eos)
124 received frame(size=9; request=1; stream=2; streamflags=stream-begin; type=stream-settings; flags=eos)
132 received frame(size=11; request=1; stream=2; streamflags=encoded; type=command-response; flags=continuation)
125 received frame(size=11; request=1; stream=2; streamflags=encoded; type=command-response; flags=continuation)
133 received frame(size=431; request=1; stream=2; streamflags=encoded; type=command-response; flags=continuation)
126 received frame(size=901; request=1; stream=2; streamflags=encoded; type=command-response; flags=continuation)
134 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
127 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
135 received frame(size=11; request=3; stream=2; streamflags=encoded; type=command-response; flags=continuation)
136 received frame(size=431; request=3; stream=2; streamflags=encoded; type=command-response; flags=continuation)
137 received frame(size=0; request=3; stream=2; streamflags=; type=command-response; flags=eos)
138 updating the branch cache
128 updating the branch cache
139 new changesets 3390ef850073:caa2a465451d (3 drafts)
129 new changesets 3390ef850073:caa2a465451d (3 drafts)
140 (sent 5 HTTP requests and * bytes; received * bytes in responses) (glob)
130 (sent 5 HTTP requests and * bytes; received * bytes in responses) (glob)
@@ -239,37 +229,27 b' Cloning only a specific revision works'
239 received frame(size=11; request=1; stream=2; streamflags=encoded; type=command-response; flags=continuation)
229 received frame(size=11; request=1; stream=2; streamflags=encoded; type=command-response; flags=continuation)
240 received frame(size=404; request=1; stream=2; streamflags=encoded; type=command-response; flags=continuation)
230 received frame(size=404; request=1; stream=2; streamflags=encoded; type=command-response; flags=continuation)
241 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
231 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
242 sending 2 commands
232 sending 1 commands
243 sending command filedata: {
233 sending command filesdata: {
244 'fields': set([
234 'fields': set([
245 'parents',
235 'parents',
246 'revision'
236 'revision'
247 ]),
237 ]),
248 'haveparents': True,
238 'haveparents': True,
239 'revisions': [
240 {
249 'nodes': [
241 'nodes': [
250 '+N\xb0s\x19\xbf\xa0w\xa4\n/\x04\x916Y\xae\xf0\xdaB\xda',
242 '3\x90\xef\x85\x00s\xfb\xc2\xf0\xdf\xff"D4,\x8e\x92)\x01:',
251 '\x9a8\x12)\x97\xb3\xac\x97\xbe*\x9a\xa2\xe5V\x83\x83A\xfd\xf2\xcc'
243 'D2\xd86&\xe8\xa9\x86U\xf0b\xec\x1f*C\xb0\x7f\x7f\xbb\xb0'
252 ],
244 ],
253 'path': 'a'
245 'type': 'changesetexplicit'
254 }
246 }
255 sending command filedata: {
247 ]
256 'fields': set([
257 'parents',
258 'revision'
259 ]),
260 'haveparents': True,
261 'nodes': [
262 '\x81\x9e%\x8d1\xa5\xe1`f)\xf3e\xbb\x90*\x1b!\xeeB\x16'
263 ],
264 'path': 'b'
265 }
248 }
266 received frame(size=9; request=1; stream=2; streamflags=stream-begin; type=stream-settings; flags=eos)
249 received frame(size=9; request=1; stream=2; streamflags=stream-begin; type=stream-settings; flags=eos)
267 received frame(size=11; request=1; stream=2; streamflags=encoded; type=command-response; flags=continuation)
250 received frame(size=11; request=1; stream=2; streamflags=encoded; type=command-response; flags=continuation)
268 received frame(size=277; request=1; stream=2; streamflags=encoded; type=command-response; flags=continuation)
251 received frame(size=439; request=1; stream=2; streamflags=encoded; type=command-response; flags=continuation)
269 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
252 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
270 received frame(size=11; request=3; stream=2; streamflags=encoded; type=command-response; flags=continuation)
271 received frame(size=123; request=3; stream=2; streamflags=encoded; type=command-response; flags=continuation)
272 received frame(size=0; request=3; stream=2; streamflags=; type=command-response; flags=eos)
273 updating the branch cache
253 updating the branch cache
274 new changesets 3390ef850073:4432d83626e8
254 new changesets 3390ef850073:4432d83626e8
275 (sent 6 HTTP requests and * bytes; received * bytes in responses) (glob)
255 (sent 6 HTTP requests and * bytes; received * bytes in responses) (glob)
@@ -357,39 +337,28 b' Incremental pull works'
357 received frame(size=11; request=1; stream=2; streamflags=encoded; type=command-response; flags=continuation)
337 received frame(size=11; request=1; stream=2; streamflags=encoded; type=command-response; flags=continuation)
358 received frame(size=601; request=1; stream=2; streamflags=encoded; type=command-response; flags=continuation)
338 received frame(size=601; request=1; stream=2; streamflags=encoded; type=command-response; flags=continuation)
359 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
339 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
360 sending 2 commands
340 sending 1 commands
361 sending command filedata: {
341 sending command filesdata: {
362 'fields': set([
342 'fields': set([
363 'parents',
343 'parents',
364 'revision'
344 'revision'
365 ]),
345 ]),
366 'haveparents': True,
346 'haveparents': True,
347 'revisions': [
348 {
367 'nodes': [
349 'nodes': [
368 '+N\xb0s\x19\xbf\xa0w\xa4\n/\x04\x916Y\xae\xf0\xdaB\xda',
350 '\xcd%4vk\xec\xe18\xc7\xc1\xaf\xdch%0/\x0fb\xd8\x1f',
369 '\xc2\xa2\x05\xc8\xb2\xad\xe2J\xf2`b\xe5<\xd5\xbc8\x01\xd6`\xda'
351 '\xe9j\xe2\x0fA\x88H{\x9a\xe4\xef9A\xc2|\x81\x141F\xe5',
352 '\xca\xa2\xa4eE\x1d\xd1\xfa\xcd\xa0\xf5\xb1#\x12\xc3UXA\x88\xa1'
370 ],
353 ],
371 'path': 'a'
354 'type': 'changesetexplicit'
372 }
355 }
373 sending command filedata: {
356 ]
374 'fields': set([
375 'parents',
376 'revision'
377 ]),
378 'haveparents': True,
379 'nodes': [
380 '\x81\x9e%\x8d1\xa5\xe1`f)\xf3e\xbb\x90*\x1b!\xeeB\x16',
381 '\xb1zk\xd3g=\x9a\xb8\xce\xd5\x81\xa2\t\xf6/=\xa5\xccEx',
382 '\xc5\xb1\xf9\xd3n\x1c\xc18\xbf\xb6\xef\xb3\xde\xb7]\x8c\xcad\x94\xc3'
383 ],
384 'path': 'b'
385 }
357 }
386 received frame(size=9; request=1; stream=2; streamflags=stream-begin; type=stream-settings; flags=eos)
358 received frame(size=9; request=1; stream=2; streamflags=stream-begin; type=stream-settings; flags=eos)
387 received frame(size=11; request=1; stream=2; streamflags=encoded; type=command-response; flags=continuation)
359 received frame(size=11; request=1; stream=2; streamflags=encoded; type=command-response; flags=continuation)
388 received frame(size=277; request=1; stream=2; streamflags=encoded; type=command-response; flags=continuation)
360 received frame(size=527; request=1; stream=2; streamflags=encoded; type=command-response; flags=continuation)
389 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
361 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
390 received frame(size=11; request=3; stream=2; streamflags=encoded; type=command-response; flags=continuation)
391 received frame(size=431; request=3; stream=2; streamflags=encoded; type=command-response; flags=continuation)
392 received frame(size=0; request=3; stream=2; streamflags=; type=command-response; flags=eos)
393 updating the branch cache
362 updating the branch cache
394 new changesets cd2534766bec:caa2a465451d (3 drafts)
363 new changesets cd2534766bec:caa2a465451d (3 drafts)
395 (run 'hg update' to get a working copy)
364 (run 'hg update' to get a working copy)
@@ -557,40 +526,30 b' Bookmarks are transferred on clone'
557 received frame(size=11; request=1; stream=2; streamflags=encoded; type=command-response; flags=continuation)
526 received frame(size=11; request=1; stream=2; streamflags=encoded; type=command-response; flags=continuation)
558 received frame(size=992; request=1; stream=2; streamflags=encoded; type=command-response; flags=continuation)
527 received frame(size=992; request=1; stream=2; streamflags=encoded; type=command-response; flags=continuation)
559 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
528 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
560 sending 2 commands
529 sending 1 commands
561 sending command filedata: {
530 sending command filesdata: {
562 'fields': set([
531 'fields': set([
563 'parents',
532 'parents',
564 'revision'
533 'revision'
565 ]),
534 ]),
566 'haveparents': True,
535 'haveparents': True,
536 'revisions': [
537 {
567 'nodes': [
538 'nodes': [
568 '+N\xb0s\x19\xbf\xa0w\xa4\n/\x04\x916Y\xae\xf0\xdaB\xda',
539 '3\x90\xef\x85\x00s\xfb\xc2\xf0\xdf\xff"D4,\x8e\x92)\x01:',
569 '\x9a8\x12)\x97\xb3\xac\x97\xbe*\x9a\xa2\xe5V\x83\x83A\xfd\xf2\xcc',
540 'D2\xd86&\xe8\xa9\x86U\xf0b\xec\x1f*C\xb0\x7f\x7f\xbb\xb0',
570 '\xc2\xa2\x05\xc8\xb2\xad\xe2J\xf2`b\xe5<\xd5\xbc8\x01\xd6`\xda'
541 '\xcd%4vk\xec\xe18\xc7\xc1\xaf\xdch%0/\x0fb\xd8\x1f',
542 '\xe9j\xe2\x0fA\x88H{\x9a\xe4\xef9A\xc2|\x81\x141F\xe5',
543 '\xca\xa2\xa4eE\x1d\xd1\xfa\xcd\xa0\xf5\xb1#\x12\xc3UXA\x88\xa1'
571 ],
544 ],
572 'path': 'a'
545 'type': 'changesetexplicit'
573 }
546 }
574 sending command filedata: {
547 ]
575 'fields': set([
576 'parents',
577 'revision'
578 ]),
579 'haveparents': True,
580 'nodes': [
581 '\x81\x9e%\x8d1\xa5\xe1`f)\xf3e\xbb\x90*\x1b!\xeeB\x16',
582 '\xb1zk\xd3g=\x9a\xb8\xce\xd5\x81\xa2\t\xf6/=\xa5\xccEx',
583 '\xc5\xb1\xf9\xd3n\x1c\xc18\xbf\xb6\xef\xb3\xde\xb7]\x8c\xcad\x94\xc3'
584 ],
585 'path': 'b'
586 }
548 }
587 received frame(size=9; request=1; stream=2; streamflags=stream-begin; type=stream-settings; flags=eos)
549 received frame(size=9; request=1; stream=2; streamflags=stream-begin; type=stream-settings; flags=eos)
588 received frame(size=11; request=1; stream=2; streamflags=encoded; type=command-response; flags=continuation)
550 received frame(size=11; request=1; stream=2; streamflags=encoded; type=command-response; flags=continuation)
589 received frame(size=431; request=1; stream=2; streamflags=encoded; type=command-response; flags=continuation)
551 received frame(size=901; request=1; stream=2; streamflags=encoded; type=command-response; flags=continuation)
590 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
552 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
591 received frame(size=11; request=3; stream=2; streamflags=encoded; type=command-response; flags=continuation)
592 received frame(size=431; request=3; stream=2; streamflags=encoded; type=command-response; flags=continuation)
593 received frame(size=0; request=3; stream=2; streamflags=; type=command-response; flags=eos)
594 updating the branch cache
553 updating the branch cache
595 new changesets 3390ef850073:caa2a465451d (1 drafts)
554 new changesets 3390ef850073:caa2a465451d (1 drafts)
596 (sent 5 HTTP requests and * bytes; received * bytes in responses) (glob)
555 (sent 5 HTTP requests and * bytes; received * bytes in responses) (glob)
General Comments 0
You need to be logged in to leave comments. Login now