hidden: support passing --hidden with `serve --stdio`
authorManuel Jacob <me@manueljacob.de>
Sat, 13 Apr 2019 03:44:47 +0200
changeset 50419 afb27fc92717
parent 50418 4bddc2f72879
child 50420 45c7bada5200
hidden: support passing --hidden with `serve --stdio` This currently has no effect since the server code will filter the repository again. However, it is clearer to put this change in its own changeset. This will mostly impact ssh peers, clients being now able to pass --hidden when spawning the server. See the next changeset for details on how this is going to be used.
mercurial/dispatch.py
--- a/mercurial/dispatch.py	Sat Apr 13 01:53:59 2019 +0200
+++ b/mercurial/dispatch.py	Sat Apr 13 03:44:47 2019 +0200
@@ -367,12 +367,18 @@
                 # shenanigans wherein a user does something like pass
                 # --debugger or --config=ui.debugger=1 as a repo
                 # name. This used to actually run the debugger.
+                nbargs = 4
+                hashiddenaccess = b'--hidden' in cmdargs
+                if hashiddenaccess:
+                    nbargs += 1
                 if (
-                    len(req.args) != 4
+                    len(req.args) != nbargs
                     or req.args[0] != b'-R'
                     or req.args[1].startswith(b'--')
                     or req.args[2] != b'serve'
                     or req.args[3] != b'--stdio'
+                    or hashiddenaccess
+                    and req.args[4] != b'--hidden'
                 ):
                     raise error.Abort(
                         _(b'potentially unsafe serve --stdio invocation: %s')