Mercurial > hg-stable
changeset 43441:88a306478556 stable
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
author | Georges Racinet <georges.racinet@octobus.net> |
---|---|
date | Wed, 20 Nov 2019 19:07:02 +0100 |
parents | 5be128f669d4 |
children | 371765e775a2 7eb701e355bd |
files | mercurial/localrepo.py tests/test-single-head.t |
diffstat | 2 files changed, 35 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/localrepo.py Thu Nov 21 17:25:24 2019 -0500 +++ b/mercurial/localrepo.py Wed Nov 20 19:07:02 2019 +0100 @@ -2086,11 +2086,10 @@ tracktags(tr2) repo = reporef() - r = repo.ui.configsuboptions( - b'experimental', b'single-head-per-branch' - ) - singlehead, singleheadsub = r + singleheadopt = (b'experimental', b'single-head-per-branch') + singlehead = repo.ui.configbool(*singleheadopt) if singlehead: + singleheadsub = repo.ui.configsuboptions(*singleheadopt)[1] accountclosed = singleheadsub.get( b"account-closed-heads", False )
--- a/tests/test-single-head.t Thu Nov 21 17:25:24 2019 -0500 +++ b/tests/test-single-head.t Wed Nov 20 19:07:02 2019 +0100 @@ -259,3 +259,35 @@ abort: rejecting multiple heads on branch "branch_A" (3 heads: 49003e504178 5254bcccab93 42b9fe70a3c1) [255] + + +Test that config can be overriden as the boolean it is +------------------------------------------------------ + + $ cat <<EOF >> $TESTTMP/single-head-server/.hg/hgrc + > [experimental] + > single-head-per-branch = no + > EOF + +Because of previous test, we'll also push c_aL0 and c_aM0. + + $ hg out -T "{desc}\n" + comparing with $TESTTMP/single-head-server + searching for changes + c_aL0 + c_aM0 + +Let's make a new head and push everythin. The server feedback will mention +exactly one new head because c_aM0 is closed. + + $ hg up 'desc("c_aG0")' + 0 files updated, 0 files merged, 2 files removed, 0 files unresolved + $ mkcommit c_aN0 + created new head + $ hg push -f + pushing to $TESTTMP/single-head-server + searching for changes + adding changesets + adding manifests + adding file changes + added 3 changesets with 3 changes to 3 files (+1 heads)