comparison mercurial/wireprotov1server.py @ 50439:4cafe20b79b6

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.
author Manuel Jacob <me@manueljacob.de>
date Sat, 13 Apr 2019 02:00:20 +0200
parents f254fc73d956
children e6948aafda6f
comparison
equal deleted inserted replaced
50438:b15b6e2c3309 50439:4cafe20b79b6
21 encoding, 21 encoding,
22 error, 22 error,
23 exchange, 23 exchange,
24 pushkey as pushkeymod, 24 pushkey as pushkeymod,
25 pycompat, 25 pycompat,
26 repoview,
26 requirements as requirementsmod, 27 requirements as requirementsmod,
27 streamclone, 28 streamclone,
28 util, 29 util,
29 wireprototypes, 30 wireprototypes,
30 ) 31 )
58 59
59 60
60 # wire protocol command can either return a string or one of these classes. 61 # wire protocol command can either return a string or one of these classes.
61 62
62 63
63 def getdispatchrepo(repo, proto, command): 64 def getdispatchrepo(repo, proto, command, accesshidden=False):
64 """Obtain the repo used for processing wire protocol commands. 65 """Obtain the repo used for processing wire protocol commands.
65 66
66 The intent of this function is to serve as a monkeypatch point for 67 The intent of this function is to serve as a monkeypatch point for
67 extensions that need commands to operate on different repo views under 68 extensions that need commands to operate on different repo views under
68 specialized circumstances. 69 specialized circumstances.
69 """ 70 """
70 viewconfig = repo.ui.config(b'server', b'view') 71 viewconfig = repo.ui.config(b'server', b'view')
72
73 # Only works if the filter actually supports being upgraded to show hidden
74 # changesets.
75 if (
76 accesshidden
77 and viewconfig is not None
78 and viewconfig + b'.hidden' in repoview.filtertable
79 ):
80 viewconfig += b'.hidden'
81
71 return repo.filtered(viewconfig) 82 return repo.filtered(viewconfig)
72 83
73 84
74 def dispatch(repo, proto, command): 85 def dispatch(repo, proto, command, accesshidden=False):
75 repo = getdispatchrepo(repo, proto, command) 86 repo = getdispatchrepo(repo, proto, command, accesshidden=accesshidden)
76 87
77 func, spec = commands[command] 88 func, spec = commands[command]
78 args = proto.getargs(spec) 89 args = proto.getargs(spec)
79 90
80 return func(repo, proto, *args) 91 return func(repo, proto, *args)