[PATCH] dispatch: do not construct repo for chgserver

Yuya Nishihara yuya at tcha.org
Fri Feb 19 09:27:36 EST 2016


On Fri, 19 Feb 2016 14:01:49 +0000, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark at fb.com>
> # Date 1455890329 0
> #      Fri Feb 19 13:58:49 2016 +0000
> # Node ID 4668ead485adb2d83dc4399d4e2ce619e70751c7
> # Parent  6c3ab048228f9b1760bf0b6baa307a4ec361c638
> dispatch: do not construct repo for chgserver
> 
> chgserver is designed to be able to serve multiple repos from one server
> process. It does not need a repo object but still needs to read repo config
> to get the final [extensions] config to know what extensions it should load.
> 
> While constructing a repo object (running reposetup) should not have bad side
> effects, it hurts performance a bit and there are some bad extensions having
> global side effects like wrapping ui in reposetup.
> 
> This patch adds special handling logic in dispatch.py to detect the chgserver
> case and skip repo object construction. It is not ideal but relatively
> reasonable comparing to other hacks like a global flag or monkey patching.
> 
> diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
> --- a/mercurial/dispatch.py
> +++ b/mercurial/dispatch.py
> @@ -873,9 +873,17 @@
>      elif not cmd:
>          return commands.help_(ui, 'shortlist')
>  
> +    norepocmd = cmd in commands.norepo.split()
> +    norepo = norepocmd
> +    cmdserver = _earlygetopt(['--cmdserver'], fullargs)
> +    # chgserver does not need repo object. one chgserver is designed to serve
> +    # multiple repos with same sensitive configs ([extensions], etc.)
> +    if cmdserver[:1] == ['chgunix'] and fullargs[:1] == ['serve']:
> +        norepo = True
> +
>      repo = None
>      cmdpats = args[:]
> -    if cmd not in commands.norepo.split():
> +    if not norepo:
>          # use the repo from the request only if we don't have -R
>          if not rpath and not cwd:
>              repo = req.repo
> @@ -914,7 +922,7 @@
>              if options['hidden']:
>                  repo = repo.unfiltered()
>          args.insert(0, repo)
> -    elif rpath:
> +    elif rpath and norepocmd:
>          ui.warn(_("warning: --repository ignored\n"))

Uh. If this is the only way to go, I would rather add a copy of "serve"
command, say "debugchgserve", and set it to "norepo" and (new) "nowarnrepo".


More information about the Mercurial-devel mailing list