Skip to content
Snippets Groups Projects
Commit c61e720d authored by Georges Racinet's avatar Georges Racinet
Browse files

High-level configuration knobs for Heptapod

These will be exposed first through the REST API
(this is heptapod#165), then we'll probably want them
to be displayed and writeable from the Web UI.

Compared to the lower level versions, they have several
advantages:

- clearer namings: the lower level knobs have names that are
  make sense independently of the context, but in Heptapod, we
  can make more assumptions about the context, and hence come
  up with something more immmediately meaningful to users
- easier to remember, less frightening (it's not more
  experimental than Heptapod itself)
- several flags can be set at once (see the case of bookmarks)

For now, the rule is that they are really inert if not
set, so that we don't interfere with tweakings of the lower
level settings our users may already have performed.

It's also the occasion to introduce `auto-publish=all`, which
makes a project entirely publishing - can be the preferred way
for some.
parent 7f926c1f
No related branches found
No related tags found
1 merge request!11High-level configuration knobs for Heptapod
Pipeline #
......@@ -38,4 +38,10 @@
configitem(b'heptapod', b'repositories-root')
configitem(b'heptapod', b'gitlab-shell')
configitem(b'heptapod', b'mirror-path')
# The following items affect other config items recognized by the core
# or by extensions. The default value should be inert, i.e., would not
# change anything, in particular would not revert to Heptapod defaults
# (as in `required.hgrc`) what local configuration or command-line options
# say.
configitem(b'heptapod', b'initial-import', False)
......@@ -41,4 +47,6 @@
configitem(b'heptapod', b'initial-import', False)
configitem(b'heptapod', b'allow-multiple-heads')
configitem(b'heptapod', b'allow-bookmarks')
cmdtable = {}
......@@ -59,6 +67,22 @@
True)
ui.setconfig(b'hggit', b'heptapod.initial-import', True)
if ui.configbool(b'heptapod', b'allow-multiple-heads'):
ui.setconfig(b'experimental', b'single-head-per-branch', False)
if ui.configbool(b'heptapod', b'allow-bookmarks'):
ui.setconfig(b'experimental', b'single-head-per-branch', False)
ui.setconfig(b'experimental',
b'hg-git.bookmarks-on-named-branches', True)
auto_publish = ui.config(b'heptapod', b'auto-publish')
if auto_publish is not None:
auto_publish = auto_publish.lower()
if auto_publish == b'nothing':
ui.setconfig(b'experimental', b'topic.publish-bare-branch', False)
elif auto_publish == b'all':
ui.setconfig(b'phases', b'publish', True)
@command(
"pull-force-topic",
......
from __future__ import absolute_import
import pytest
from heptapod.testhelpers import LocalRepoWrapper
from .utils import common_config
parametrize = pytest.mark.parametrize
def make_repo(tmpdir, config):
full_config = common_config()
full_config.update(config)
wrapper = LocalRepoWrapper.init(tmpdir.join('repo'), config=full_config)
return wrapper.repo.ui
def test_multiple_heads_allow(tmpdir):
ui = make_repo(tmpdir,
config=dict(heptapod={'allow-multiple-heads': 'yes'},
experimental={'single-head-per-branch': 'no'},
))
assert not ui.configbool('experimental', 'single-head-per-branch')
def test_bookmarks_allow(tmpdir):
ui = make_repo(tmpdir,
config=dict(heptapod={'allow-bookmarks': 'yes'},
))
assert not ui.configbool('experimental', 'single-head-per-branch')
assert ui.configbool('experimental', 'hg-git.bookmarks-on-named-branches')
def test_auto_publish_nothing(tmpdir):
ui = make_repo(tmpdir,
config=dict(
heptapod={'auto-publish': 'nothing'},
experimental={'topic.publish-bare-branch': 'yes'},
))
assert not ui.configbool('experimental', 'topic.publish-bare-branch')
def test_auto_publish_all(tmpdir):
ui = make_repo(tmpdir,
config=dict(
heptapod={'auto-publish': 'all'},
phases={'publish': 'no'},
))
assert ui.configbool('phases', 'publish')
@parametrize('key',
[('experimental', 'single-head-per-branch'),
('experimental', 'hg-git.bookmarks-on-named-branches'),
('experimental', 'topic.publish-bare-branch'),
('phases', 'publish'),
])
@parametrize('value', [True, False])
def test_lower_level_config_untouched(tmpdir, key, value):
"""This case is the default config in Heptapod normal conditions."""
section, item = key
ui = make_repo(tmpdir, config={section: {item: value}})
assert ui.configbool(section, item) == value
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment