[PATCH] wireproto: extract repo filtering to standalone function
Augie Fackler
raf at durin42.com
Mon Jul 18 11:59:02 UTC 2016
On Fri, Jul 15, 2016 at 02:01:34PM -0700, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc at gmail.com>
> # Date 1468615294 25200
> # Fri Jul 15 13:41:34 2016 -0700
> # Node ID b0044e5fa986a7cb09fd32d44a3c7aac45086183
> # Parent 9d02bed8477bec7f679d6aeb5b1dd8bcdb80f64d
> wireproto: extract repo filtering to standalone function
Queued, thanks
>
> 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 --git a/mercurial/wireproto.py b/mercurial/wireproto.py
> --- a/mercurial/wireproto.py
> +++ b/mercurial/wireproto.py
> @@ -531,18 +531,27 @@ class ooberror(object):
> """wireproto reply: failure of a batch of operation
>
> Something failed during a batch call. The error message is stored in
> `self.message`.
> """
> 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)
>
> def options(cmd, keys, others):
> opts = {}
> for k in keys:
> if k in others:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list