Mercurial > public > mercurial-scm > hg-stable
diff mercurial/sshpeer.py @ 50481:45c7bada5200
hidden: add support to explicitly access hidden changesets with SSH peers
This implements support for using --remote-hidden with an SSH server. The
remote `hg serve --stdio` call is passed the `--hidden` flag as a request to
access hidden changesets.
This approach has benefits similar to the one we used for HTTP peers. It
* works around the lack of global parameters in wire protocol v1,
* reuses the `--hidden` flag (that does not use the wireproto), and
* can be safely ignored by older client (fitting the best effort contract).
Same as for HTTP, the feature is experimental so we have all the room we needs
to update the implementation in the future if deemed necessary.
The SSH version of the `--remote-hidden` config uses the same configuration as
the HTTP support to control the access to this feature. The name of the user
running the command is used for the checking.
Test written by Pierre-Yves David.
author | Manuel Jacob <me@manueljacob.de> |
---|---|
date | Sat, 13 Apr 2019 03:44:55 +0200 |
parents | 3a2df812e1c7 |
children | 60f9602b413e |
line wrap: on
line diff
--- a/mercurial/sshpeer.py Sat Apr 13 03:44:47 2019 +0200 +++ b/mercurial/sshpeer.py Sat Apr 13 03:44:55 2019 +0200 @@ -177,7 +177,9 @@ ui.develwarn(b'missing close on SSH connection created at:\n%s' % warn) -def _makeconnection(ui, sshcmd, args, remotecmd, path, sshenv=None): +def _makeconnection( + ui, sshcmd, args, remotecmd, path, sshenv=None, remotehidden=False +): """Create an SSH connection to a server. Returns a tuple of (process, stdin, stdout, stderr) for the @@ -187,8 +189,12 @@ sshcmd, args, procutil.shellquote( - b'%s -R %s serve --stdio' - % (_serverquote(remotecmd), _serverquote(path)) + b'%s -R %s serve --stdio%s' + % ( + _serverquote(remotecmd), + _serverquote(path), + b' --hidden' if remotehidden else b'', + ) ), ) @@ -393,13 +399,6 @@ stderr and to forward its output. """ super().__init__(ui, path=path, remotehidden=remotehidden) - if remotehidden: - msg = _( - b"ignoring `--remote-hidden` request\n" - b"(access to hidden changeset for ssh peers not supported " - b"yet)\n" - ) - ui.warn(msg) # self._subprocess is unused. Keeping a handle on the process # holds a reference and prevents it from being garbage collected. self._subprocess = proc @@ -416,6 +415,7 @@ self._caps = caps self._autoreadstderr = autoreadstderr self._initstack = b''.join(util.getstackframes(1)) + self._remotehidden = remotehidden # Commands that have a "framed" response where the first line of the # response contains the length of that response. @@ -683,7 +683,13 @@ raise error.RepoError(_(b'could not create remote repo')) proc, stdin, stdout, stderr = _makeconnection( - ui, sshcmd, args, remotecmd, remotepath, sshenv + ui, + sshcmd, + args, + remotecmd, + remotepath, + sshenv, + remotehidden=remotehidden, ) peer = _make_peer(