Mercurial > hg
comparison mercurial/wireprotov1peer.py @ 37646:72e26319f3b8
wireproto: use command executor for unbundle
This also required unifying the name of the argument because the
new API always passes arguments by keyword. I decided to change
implementations to "bundle" instead of the interface to "cg"
because "bundle" is more appropriate in a modern world.
Differential Revision: https://phab.mercurial-scm.org/D3314
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Fri, 13 Apr 2018 11:30:44 -0700 |
parents | cc8c06835097 |
children | a168799687e5 |
comparison
equal
deleted
inserted
replaced
37645:72b0982cd509 | 37646:72e26319f3b8 |
---|---|
434 if any((cap.startswith('HG2') for cap in bundlecaps)): | 434 if any((cap.startswith('HG2') for cap in bundlecaps)): |
435 return bundle2.getunbundler(self.ui, f) | 435 return bundle2.getunbundler(self.ui, f) |
436 else: | 436 else: |
437 return changegroupmod.cg1unpacker(f, 'UN') | 437 return changegroupmod.cg1unpacker(f, 'UN') |
438 | 438 |
439 def unbundle(self, cg, heads, url): | 439 def unbundle(self, bundle, heads, url): |
440 '''Send cg (a readable file-like object representing the | 440 '''Send cg (a readable file-like object representing the |
441 changegroup to push, typically a chunkbuffer object) to the | 441 changegroup to push, typically a chunkbuffer object) to the |
442 remote server as a bundle. | 442 remote server as a bundle. |
443 | 443 |
444 When pushing a bundle10 stream, return an integer indicating the | 444 When pushing a bundle10 stream, return an integer indicating the |
454 heads = wireprototypes.encodelist( | 454 heads = wireprototypes.encodelist( |
455 ['hashed', hashlib.sha1(''.join(sorted(heads))).digest()]) | 455 ['hashed', hashlib.sha1(''.join(sorted(heads))).digest()]) |
456 else: | 456 else: |
457 heads = wireprototypes.encodelist(heads) | 457 heads = wireprototypes.encodelist(heads) |
458 | 458 |
459 if util.safehasattr(cg, 'deltaheader'): | 459 if util.safehasattr(bundle, 'deltaheader'): |
460 # this a bundle10, do the old style call sequence | 460 # this a bundle10, do the old style call sequence |
461 ret, output = self._callpush("unbundle", cg, heads=heads) | 461 ret, output = self._callpush("unbundle", bundle, heads=heads) |
462 if ret == "": | 462 if ret == "": |
463 raise error.ResponseError( | 463 raise error.ResponseError( |
464 _('push failed:'), output) | 464 _('push failed:'), output) |
465 try: | 465 try: |
466 ret = int(ret) | 466 ret = int(ret) |
470 | 470 |
471 for l in output.splitlines(True): | 471 for l in output.splitlines(True): |
472 self.ui.status(_('remote: '), l) | 472 self.ui.status(_('remote: '), l) |
473 else: | 473 else: |
474 # bundle2 push. Send a stream, fetch a stream. | 474 # bundle2 push. Send a stream, fetch a stream. |
475 stream = self._calltwowaystream('unbundle', cg, heads=heads) | 475 stream = self._calltwowaystream('unbundle', bundle, heads=heads) |
476 ret = bundle2.getunbundler(self.ui, stream) | 476 ret = bundle2.getunbundler(self.ui, stream) |
477 return ret | 477 return ret |
478 | 478 |
479 # End of ipeercommands interface. | 479 # End of ipeercommands interface. |
480 | 480 |