Mercurial > public > mercurial-scm > hg-stable
diff mercurial/wireprotoserver.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 | 3b199593fedd |
children | 13c004b54cbe |
line wrap: on
line diff
--- a/mercurial/wireprotoserver.py Sat Apr 13 03:44:47 2019 +0200 +++ b/mercurial/wireprotoserver.py Sat Apr 13 03:44:55 2019 +0200 @@ -446,7 +446,7 @@ pass -def _runsshserver(ui, repo, fin, fout, ev): +def _runsshserver(ui, repo, fin, fout, ev, accesshidden=False): # This function operates like a state machine of sorts. The following # states are defined: # @@ -487,7 +487,9 @@ _sshv1respondbytes(fout, b'') continue - rsp = wireprotov1server.dispatch(repo, proto, request) + rsp = wireprotov1server.dispatch( + repo, proto, request, accesshidden=accesshidden + ) repo.ui.fout.flush() repo.ui.ferr.flush() @@ -522,10 +524,11 @@ class sshserver: - def __init__(self, ui, repo, logfh=None): + def __init__(self, ui, repo, logfh=None, accesshidden=False): self._ui = ui self._repo = repo self._fin, self._fout = ui.protectfinout() + self._accesshidden = accesshidden # Log write I/O to stdout and stderr if configured. if logfh: @@ -542,4 +545,6 @@ def serveuntil(self, ev): """Serve until a threading.Event is set.""" - _runsshserver(self._ui, self._repo, self._fin, self._fout, ev) + _runsshserver( + self._ui, self._repo, self._fin, self._fout, ev, self._accesshidden + )