341 return changegroupmod.unbundle10(f, 'UN') |
341 return changegroupmod.unbundle10(f, 'UN') |
342 |
342 |
343 def unbundle(self, cg, heads, source): |
343 def unbundle(self, cg, heads, source): |
344 '''Send cg (a readable file-like object representing the |
344 '''Send cg (a readable file-like object representing the |
345 changegroup to push, typically a chunkbuffer object) to the |
345 changegroup to push, typically a chunkbuffer object) to the |
346 remote server as a bundle. Return an integer indicating the |
346 remote server as a bundle. |
347 result of the push (see localrepository.addchangegroup()).''' |
347 |
|
348 When pushing a bundle10 stream, return an integer indicating the |
|
349 result of the push (see localrepository.addchangegroup()). |
|
350 |
|
351 When pushing a bundle20 stream, return a bundle20 stream.''' |
348 |
352 |
349 if heads != ['force'] and self.capable('unbundlehash'): |
353 if heads != ['force'] and self.capable('unbundlehash'): |
350 heads = encodelist(['hashed', |
354 heads = encodelist(['hashed', |
351 util.sha1(''.join(sorted(heads))).digest()]) |
355 util.sha1(''.join(sorted(heads))).digest()]) |
352 else: |
356 else: |
353 heads = encodelist(heads) |
357 heads = encodelist(heads) |
354 |
358 |
355 ret, output = self._callpush("unbundle", cg, heads=heads) |
359 if util.safehasattr(cg, 'deltaheader'): |
356 if ret == "": |
360 # this a bundle10, do the old style call sequence |
357 raise error.ResponseError( |
361 ret, output = self._callpush("unbundle", cg, heads=heads) |
358 _('push failed:'), output) |
362 if ret == "": |
359 try: |
363 raise error.ResponseError( |
360 ret = int(ret) |
364 _('push failed:'), output) |
361 except ValueError: |
365 try: |
362 raise error.ResponseError( |
366 ret = int(ret) |
363 _('push failed (unexpected response):'), ret) |
367 except ValueError: |
364 |
368 raise error.ResponseError( |
365 for l in output.splitlines(True): |
369 _('push failed (unexpected response):'), ret) |
366 self.ui.status(_('remote: '), l) |
370 |
|
371 for l in output.splitlines(True): |
|
372 self.ui.status(_('remote: '), l) |
|
373 else: |
|
374 # bundle2 push. Send a stream, fetch a stream. |
|
375 stream = self._calltwowaystream('unbundle', cg, heads=heads) |
|
376 ret = bundle2.unbundle20(self.ui, stream) |
367 return ret |
377 return ret |
368 |
378 |
369 def debugwireargs(self, one, two, three=None, four=None, five=None): |
379 def debugwireargs(self, one, two, three=None, four=None, five=None): |
370 # don't pass optional arguments left at their default value |
380 # don't pass optional arguments left at their default value |
371 opts = {} |
381 opts = {} |
779 proto.getfile(fp) |
789 proto.getfile(fp) |
780 fp.seek(0) |
790 fp.seek(0) |
781 gen = exchange.readbundle(repo.ui, fp, None) |
791 gen = exchange.readbundle(repo.ui, fp, None) |
782 r = exchange.unbundle(repo, gen, their_heads, 'serve', |
792 r = exchange.unbundle(repo, gen, their_heads, 'serve', |
783 proto._client()) |
793 proto._client()) |
|
794 if util.safehasattr(r, 'addpart'): |
|
795 # The return looks streameable, we are in the bundle2 case and |
|
796 # should return a stream. |
|
797 return streamres(r.getchunks()) |
784 return pushres(r) |
798 return pushres(r) |
785 |
799 |
786 finally: |
800 finally: |
787 fp.close() |
801 fp.close() |
788 os.unlink(tempname) |
802 os.unlink(tempname) |