On 11/21/19 1:38 PM, Yuya Nishihara wrote:
On Wed, 20 Nov 2019 19:23:26 +0100, Georges Racinet wrote:
# HG changeset patch
# User Georges Racinet <georges.raci...@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)
Thanks for having looked at this
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(...)

I wasn't sure whether it'd be a bit slower because of redoing partly what `configsuboptions` had already done.

Then why not make explicit that we don't want the first value given by `configsuboptions`,, then :

_, singleheadsub = ui.configsuboptions(...)         (or even singleheadsub = ui.configsuboptions(...)[1])

singlehead = ui.configbool(...)

I'll amend and resubmit according to your prefererence

--
Georges Racinet
https://octobus.net, https://hetpapod.net
GPG: BF5456F4DC625443849B6E58EE20CA44EF691D39, sur serveurs publics

_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to