mercurial/wireproto.py
branchstable
changeset 30909 d554e624c5fe
parent 30762 35b516f800e0
child 30910 accaa04f951c
--- a/mercurial/wireproto.py	Fri Feb 10 17:56:47 2017 +0100
+++ b/mercurial/wireproto.py	Fri Feb 10 17:56:59 2017 +0100
@@ -33,9 +33,10 @@
 urlerr = util.urlerr
 urlreq = util.urlreq
 
-bundle2required = _(
-    'incompatible Mercurial client; bundle2 required\n'
-    '(see https://www.mercurial-scm.org/wiki/IncompatibleClient)\n')
+bundle2requiredmain = _('incompatible Mercurial client; bundle2 required')
+bundle2requiredhint = _('see https://www.mercurial-scm.org/wiki/'
+                        'IncompatibleClient')
+bundle2required = '%s\n(%s)\n' % (bundle2requiredmain, bundle2requiredhint)
 
 class abstractserverproto(object):
     """abstract class that summarizes the protocol API
@@ -948,7 +949,14 @@
             gen = exchange.readbundle(repo.ui, fp, None)
             if (isinstance(gen, changegroupmod.cg1unpacker)
                 and not bundle1allowed(repo, 'push')):
-                return ooberror(bundle2required)
+                if proto.name == 'http':
+                    # need to special case http because stderr do not get to
+                    # the http client on failed push so we need to abuse some
+                    # other error type to make sure the message get to the
+                    # user.
+                    return ooberror(bundle2required)
+                raise error.Abort(bundle2requiredmain,
+                                  hint=bundle2requiredhint)
 
             r = exchange.unbundle(repo, gen, their_heads, 'serve',
                                   proto._client())