hidden: support for explicitly accessing hidden changesets in wireproto server
authorManuel Jacob <me@manueljacob.de>
Sat, 13 Apr 2019 02:00:20 +0200
changeset 50415 4cafe20b79b6
parent 50414 b15b6e2c3309
child 50416 3b199593fedd
hidden: support for explicitly accessing hidden changesets in wireproto server This installs the basic infrastructure to be able to access hidden changeset through the wireprotocol. Each wireprotocol server still needs a way to define how the feature is triggered.
mercurial/wireprotov1server.py
--- a/mercurial/wireprotov1server.py	Fri Apr 05 12:11:52 2019 +0200
+++ b/mercurial/wireprotov1server.py	Sat Apr 13 02:00:20 2019 +0200
@@ -23,6 +23,7 @@
     exchange,
     pushkey as pushkeymod,
     pycompat,
+    repoview,
     requirements as requirementsmod,
     streamclone,
     util,
@@ -60,7 +61,7 @@
 # wire protocol command can either return a string or one of these classes.
 
 
-def getdispatchrepo(repo, proto, command):
+def getdispatchrepo(repo, proto, command, accesshidden=False):
     """Obtain the repo used for processing wire protocol commands.
 
     The intent of this function is to serve as a monkeypatch point for
@@ -68,11 +69,21 @@
     specialized circumstances.
     """
     viewconfig = repo.ui.config(b'server', b'view')
+
+    # Only works if the filter actually supports being upgraded to show hidden
+    # changesets.
+    if (
+        accesshidden
+        and viewconfig is not None
+        and viewconfig + b'.hidden' in repoview.filtertable
+    ):
+        viewconfig += b'.hidden'
+
     return repo.filtered(viewconfig)
 
 
-def dispatch(repo, proto, command):
-    repo = getdispatchrepo(repo, proto, command)
+def dispatch(repo, proto, command, accesshidden=False):
+    repo = getdispatchrepo(repo, proto, command, accesshidden=accesshidden)
 
     func, spec = commands[command]
     args = proto.getargs(spec)