comparison mercurial/wireproto.py @ 29590:84c1a5942f1d

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.
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 15 Jul 2016 13:41:34 -0700
parents 0d83ad967bf8
children 7f6130c7ffe1
comparison
equal deleted inserted replaced
29589:486de14eb394 29590:84c1a5942f1d
534 `self.message`. 534 `self.message`.
535 """ 535 """
536 def __init__(self, message): 536 def __init__(self, message):
537 self.message = message 537 self.message = message
538 538
539 def getdispatchrepo(repo, proto, command):
540 """Obtain the repo used for processing wire protocol commands.
541
542 The intent of this function is to serve as a monkeypatch point for
543 extensions that need commands to operate on different repo views under
544 specialized circumstances.
545 """
546 return repo.filtered('served')
547
539 def dispatch(repo, proto, command): 548 def dispatch(repo, proto, command):
540 repo = repo.filtered("served") 549 repo = getdispatchrepo(repo, proto, command)
541 func, spec = commands[command] 550 func, spec = commands[command]
542 args = proto.getargs(spec) 551 args = proto.getargs(spec)
543 return func(repo, proto, *args) 552 return func(repo, proto, *args)
544 553
545 def options(cmd, keys, others): 554 def options(cmd, keys, others):