[PATCH 5 of 5 V2] chgserver: make _renewui load repo and command line configs

Yuya Nishihara yuya at tcha.org
Sat Feb 27 02:25:45 EST 2016


On Fri, 26 Feb 2016 15:36:24 +0000, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark at fb.com>
> # Date 1456500166 0
> #      Fri Feb 26 15:22:46 2016 +0000
> # Node ID ac5273f401959e4b584591363f1700ef7df56fe8
> # Parent  93c4a18979328bf50acb2132c031d96fdda46bfc
> chgserver: make _renewui load repo and command line configs

Queued 1, 4 and 5, thanks. 3 looks good but it depends on 2.

> +def _renewui(srcui, args=None):
> +    if not args:
> +        args = []
> +
>      newui = srcui.__class__()
>      for a in ['fin', 'fout', 'ferr', 'environ']:
>          setattr(newui, a, getattr(srcui, a))
>      if util.safehasattr(srcui, '_csystem'):
>          newui._csystem = srcui._csystem
> +
> +    # load wd and repo config, copied from dispatch.py
> +    cwds = dispatch._earlygetopt(['--cwd'], args)
> +    cwd = cwds and os.path.realpath(cwds[-1]) or None
> +    rpath = dispatch._earlygetopt(["-R", "--repository", "--repo"], args)
> +    path, newui = dispatch._getlocal(newui, rpath, wd=cwd)
> +
> +    # internal config: extensions.chgserver
> +    # copy it. it can only be overrided from command line.
> +    newui.setconfig('extensions', 'chgserver',
> +                    srcui.config('extensions', 'chgserver'), '--config')
> +
> +    # command line args
> +    dispatch._parseconfig(newui, dispatch._earlygetopt(['--config'], args))
> +
>      # stolen from tortoisehg.util.copydynamicconfig()
>      for section, name, value in srcui.walkconfig():
>          source = srcui.configsource(section, name)
> -        if ':' in source:
> -            # path:line
> +        if ':' in source or source == '--config':
> +            # path:line or command line

'--config' would be lost if _renewui() is called without args, but I expect
the current use of _renewui() will be superseded by the config hash. So that's
okay.


More information about the Mercurial-devel mailing list