Patchwork [5,of,7,stable] bundle1: fix bundle1-denied reporting for pull over ssh

login
register
mail settings
Submitter Pierre-Yves David
Date Feb. 10, 2017, 5:53 p.m.
Message ID <fcb3f4f9e1f60459e135.1486749186@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/18405/
State Accepted
Delegated to: Martin von Zweigbergk
Headers show

Comments

Pierre-Yves David - Feb. 10, 2017, 5:53 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1486746368 -3600
#      Fri Feb 10 18:06:08 2017 +0100
# Branch stable
# Node ID fcb3f4f9e1f60459e13588a66861ab50835a09e9
# Parent  27ef75df203505964fbb20ac38ba737c3564d1a8
# EXP-Topic getbundleerror
bundle1: fix bundle1-denied reporting for pull over ssh

Changeset b288fb2724bf introduced a config option to have the server deny pull
using bundle1. The original protocol has not really been design to allow that
kind of error reporting so some hack was used. It turned the hack only works on
HTTP and that ssh server hangs forever when this is used. After further
digging, there is no way to report the error in a unified way. Using `ooberror`
freeze ssh and raising 'Abort' makes HTTP return a HTTP-500 without further
details. So with sadness we implement a version that dispatch according to the
protocol used.

Now the error is properly reported, but we still have ungraceful abort after
that. The protocol do not allow anything better to happen using bundle1.

Patch

diff -r 27ef75df2035 -r fcb3f4f9e1f6 mercurial/wireproto.py
--- a/mercurial/wireproto.py	Fri Feb 10 18:06:12 2017 +0100
+++ b/mercurial/wireproto.py	Fri Feb 10 18:06:08 2017 +0100
@@ -834,7 +834,10 @@ 
 
     if not bundle1allowed(repo, 'pull'):
         if not exchange.bundle2requested(opts.get('bundlecaps')):
-            return ooberror(bundle2required)
+            if proto.name == 'http':
+                return ooberror(bundle2required)
+            raise error.Abort(bundle2requiredmain,
+                              hint=bundle2requiredhint)
 
     chunks = exchange.getbundlechunks(repo, 'serve', **opts)
     return streamres(gen=chunks, v1compressible=True)
diff -r 27ef75df2035 -r fcb3f4f9e1f6 tests/test-bundle2-exchange.t
--- a/tests/test-bundle2-exchange.t	Fri Feb 10 18:06:12 2017 +0100
+++ b/tests/test-bundle2-exchange.t	Fri Feb 10 18:06:08 2017 +0100
@@ -1039,6 +1039,16 @@ 
   [255]
   $ killdaemons.py
 
+  $ hg --config devel.legacy.exchange=bundle1 clone ssh://user@dummy/bundle2onlyserver not-bundle2-ssh
+  requesting all changes
+  adding changesets
+  remote: abort: incompatible Mercurial client; bundle2 required
+  remote: (see https://www.mercurial-scm.org/wiki/IncompatibleClient)
+  transaction abort!
+  rollback completed
+  abort: stream ended unexpectedly (got 0 bytes, expected 4)
+  [255]
+
   $ cat > bundle2onlyserver/.hg/hgrc << EOF
   > [server]
   > bundle1gd = false