Mercurial > hg
comparison mercurial/wireproto.py @ 21177:952af771bc17 stable
bundle2: gracefully handle abort during unbundle
Clients expect a bundle2 reply to their bundle2 submission. So we
catch the Abort error and turn it into a bundle2 containing a part
transporting the exception data. The unbundling of this reply will
raise the error again.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Mon, 21 Apr 2014 15:48:52 -0700 |
parents | 60ad2ea5b106 |
children | 4345274adc4b |
comparison
equal
deleted
inserted
replaced
21176:70fcb0a71445 | 21177:952af771bc17 |
---|---|
806 except util.Abort, inst: | 806 except util.Abort, inst: |
807 # The old code we moved used sys.stderr directly. | 807 # The old code we moved used sys.stderr directly. |
808 # We did not change it to minimise code change. | 808 # We did not change it to minimise code change. |
809 # This need to be moved to something proper. | 809 # This need to be moved to something proper. |
810 # Feel free to do it. | 810 # Feel free to do it. |
811 sys.stderr.write("abort: %s\n" % inst) | 811 if getattr(inst, 'duringunbundle2', False): |
812 return pushres(0) | 812 bundler = bundle2.bundle20(repo.ui) |
813 manargs = [('message', str(inst))] | |
814 advargs = [] | |
815 if inst.hint is not None: | |
816 advargs.append(('hint', inst.hint)) | |
817 bundler.addpart(bundle2.bundlepart('B2X:ERROR:ABORT', | |
818 manargs, advargs)) | |
819 return streamres(bundler.getchunks()) | |
820 else: | |
821 sys.stderr.write("abort: %s\n" % inst) | |
822 return pushres(0) | |
813 except exchange.PushRaced, exc: | 823 except exchange.PushRaced, exc: |
814 return pusherr(str(exc)) | 824 return pusherr(str(exc)) |