[PATCH STABLE] singlehead: making config item a bool again

Yuya Nishihara yuya at tcha.org
Thu Nov 21 07:38:04 EST 2019


On Wed, 20 Nov 2019 19:23:26 +0100, Georges Racinet wrote:
> # HG changeset patch
> # User Georges Racinet <georges.racinet at octobus.net>
> # Date 1574273222 -3600
> #      Wed Nov 20 19:07:02 2019 +0100
> # Branch stable
> # Node ID c557e15674ea6adfe1b034e5b4af1e26bca850dd
> # Parent  ca3dca416f8d5863ca6f5a4a6a6bb835dcd5feeb
> # EXP-Topic single_head_is_boolean
> singlehead: making config item a bool again
> 
> with the use of `configsuboptions`, the main config item has become
> a string (unless it's just the default value).
> 
> This makes it in particular hard to override in a cascade of HGRC files,
> as we do in Heptapod to re-allow multiple heads on specific repositories
> while the default behaviour is to forbid them. The added test case reflects
> that use-case
> 
> diff -r ca3dca416f8d -r c557e15674ea mercurial/localrepo.py
> --- a/mercurial/localrepo.py	Tue Nov 05 21:35:19 2019 +0900
> +++ b/mercurial/localrepo.py	Wed Nov 20 19:07:02 2019 +0100
> @@ -2090,6 +2090,8 @@
>                  b'experimental', b'single-head-per-branch'
>              )
>              singlehead, singleheadsub = r
> +            if singlehead is not None and not isinstance(singlehead, bool):
> +                singlehead = stringutil.parsebool(singlehead)

Maybe it's better to use ui.configbool() to check if the config value can
be parsed as bool.

  singlehead, singleheadsub = ui.configsuboptions(...)
  singlehead = ui.configbool(...)


More information about the Mercurial-devel mailing list