# HG changeset patch # User Gregory Szorc # Date 1468615294 25200 # Node ID 84c1a5942f1d24cd34d38a498113226b93fb0588 # Parent 486de14eb394e9885cbc55156544d63c0bfd7972 wireproto: extract repo filtering to standalone function As part of teaching Mozilla's replication extension to better handle repositories with obsolescence data, I encountered a few scenarios where I wanted built-in wire protocol commands from replication clients to operate on unfiltered repositories so they could have access to obsolete changesets. While the undocumented "web.view" config option provides a mechanism to choose what filter/view hgweb operates on, this doesn't apply to wire protocol commands because wireproto.dispatch() is always operating on the "served" repo. This patch extracts the line for obtaining the repo that wireproto commands operate on to its own function so extensions can monkeypatch it to e.g. return an unfiltered repo. I stopped short of exposing a config option because I view the use case for changing this as a niche feature, best left to the domain of extensions. diff -r 486de14eb394 -r 84c1a5942f1d mercurial/wireproto.py --- a/mercurial/wireproto.py Thu Jul 14 19:16:46 2016 -0700 +++ b/mercurial/wireproto.py Fri Jul 15 13:41:34 2016 -0700 @@ -536,8 +536,17 @@ def __init__(self, message): self.message = message +def getdispatchrepo(repo, proto, command): + """Obtain the repo used for processing wire protocol commands. + + The intent of this function is to serve as a monkeypatch point for + extensions that need commands to operate on different repo views under + specialized circumstances. + """ + return repo.filtered('served') + def dispatch(repo, proto, command): - repo = repo.filtered("served") + repo = getdispatchrepo(repo, proto, command) func, spec = commands[command] args = proto.getargs(spec) return func(repo, proto, *args)