Mercurial > hg
diff mercurial/wireproto.py @ 25493:d8e7b0781ad7
bundle2: convey PushkeyFailed error over the wire
We add a way to convey the precise exception. This will allow better error
message on the server.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Wed, 10 Jun 2015 13:10:53 -0400 |
parents | 30ab130af221 |
children | 328739ea70c3 |
line wrap: on
line diff
--- a/mercurial/wireproto.py Sat Jun 06 00:50:27 2015 -0700 +++ b/mercurial/wireproto.py Wed Jun 10 13:10:53 2015 -0400 @@ -819,7 +819,27 @@ for out in getattr(exc, '_bundle2salvagedoutput', ()): bundler.addpart(out) try: - raise + try: + raise + except error.PushkeyFailed, exc: + # check client caps + remotecaps = getattr(exc, '_replycaps', None) + if (remotecaps is not None + and 'pushkey' not in remotecaps.get('error', ())): + # no support remote side, fallback to Abort handler. + raise + part = bundler.newpart('error:pushkey') + part.addparam('in-reply-to', exc.partid) + if exc.namespace is not None: + part.addparam('namespace', exc.namespace, mandatory=False) + if exc.key is not None: + part.addparam('key', exc.key, mandatory=False) + if exc.new is not None: + part.addparam('new', exc.new, mandatory=False) + if exc.old is not None: + part.addparam('old', exc.old, mandatory=False) + if exc.ret is not None: + part.addparam('ret', exc.ret, mandatory=False) except error.BundleValueError, exc: errpart = bundler.newpart('error:unsupportedcontent') if exc.parttype is not None: