comparison mercurial/wireprotov1server.py @ 45682:d2e1dcd4490d

errors: name arguments to Abort constructor Differential Revision: https://phab.mercurial-scm.org/D9179
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 08 Oct 2020 13:37:31 -0700
parents c93dd9d9f1e6
children 74271829ddc0
comparison
equal deleted inserted replaced
45681:a736ab681b78 45682:d2e1dcd4490d
495 prefercompressed = info.get(b'prefercompressed', True) 495 prefercompressed = info.get(b'prefercompressed', True)
496 except error.Abort as exc: 496 except error.Abort as exc:
497 # cleanly forward Abort error to the client 497 # cleanly forward Abort error to the client
498 if not exchange.bundle2requested(opts.get(b'bundlecaps')): 498 if not exchange.bundle2requested(opts.get(b'bundlecaps')):
499 if proto.name == b'http-v1': 499 if proto.name == b'http-v1':
500 return wireprototypes.ooberror(pycompat.bytestr(exc) + b'\n') 500 return wireprototypes.ooberror(exc.message + b'\n')
501 raise # cannot do better for bundle1 + ssh 501 raise # cannot do better for bundle1 + ssh
502 # bundle2 request expect a bundle2 reply 502 # bundle2 request expect a bundle2 reply
503 bundler = bundle2.bundle20(repo.ui) 503 bundler = bundle2.bundle20(repo.ui)
504 manargs = [(b'message', pycompat.bytestr(exc))] 504 manargs = [(b'message', exc.message)]
505 advargs = [] 505 advargs = []
506 if exc.hint is not None: 506 if exc.hint is not None:
507 advargs.append((b'hint', exc.hint)) 507 advargs.append((b'hint', exc.hint))
508 bundler.addpart(bundle2.bundlepart(b'error:abort', manargs, advargs)) 508 bundler.addpart(bundle2.bundlepart(b'error:abort', manargs, advargs))
509 chunks = bundler.getchunks() 509 chunks = bundler.getchunks()
682 except error.Abort as exc: 682 except error.Abort as exc:
683 # The old code we moved used procutil.stderr directly. 683 # The old code we moved used procutil.stderr directly.
684 # We did not change it to minimise code change. 684 # We did not change it to minimise code change.
685 # This need to be moved to something proper. 685 # This need to be moved to something proper.
686 # Feel free to do it. 686 # Feel free to do it.
687 procutil.stderr.write(b"abort: %s\n" % exc) 687 procutil.stderr.write(b"abort: %s\n" % exc.message)
688 if exc.hint is not None: 688 if exc.hint is not None:
689 procutil.stderr.write(b"(%s)\n" % exc.hint) 689 procutil.stderr.write(b"(%s)\n" % exc.hint)
690 procutil.stderr.flush() 690 procutil.stderr.flush()
691 return wireprototypes.pushres( 691 return wireprototypes.pushres(
692 0, output.getvalue() if output else b'' 692 0, output.getvalue() if output else b''
731 if exc.parttype is not None: 731 if exc.parttype is not None:
732 errpart.addparam(b'parttype', exc.parttype) 732 errpart.addparam(b'parttype', exc.parttype)
733 if exc.params: 733 if exc.params:
734 errpart.addparam(b'params', b'\0'.join(exc.params)) 734 errpart.addparam(b'params', b'\0'.join(exc.params))
735 except error.Abort as exc: 735 except error.Abort as exc:
736 manargs = [(b'message', stringutil.forcebytestr(exc))] 736 manargs = [(b'message', exc.message)]
737 advargs = [] 737 advargs = []
738 if exc.hint is not None: 738 if exc.hint is not None:
739 advargs.append((b'hint', exc.hint)) 739 advargs.append((b'hint', exc.hint))
740 bundler.addpart( 740 bundler.addpart(
741 bundle2.bundlepart(b'error:abort', manargs, advargs) 741 bundle2.bundlepart(b'error:abort', manargs, advargs)