Rev 5464: Rename config --force to config --scope. in file:///home/vila/src/bzr/experimental/config/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Wed Oct 13 15:14:38 BST 2010
At file:///home/vila/src/bzr/experimental/config/
------------------------------------------------------------
revno: 5464
revision-id: v.ladeuil+lp at free.fr-20101013141437-emlr4irn6vkbp42c
parent: v.ladeuil+lp at free.fr-20101013140632-ofxvtfvji3pk5gb8
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: config-modify
timestamp: Wed 2010-10-13 16:14:37 +0200
message:
Rename config --force to config --scope.
-------------- next part --------------
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py 2010-10-13 14:06:32 +0000
+++ b/bzrlib/config.py 2010-10-13 14:14:37 +0000
@@ -1780,44 +1780,44 @@
'directory',
# FIXME: This should be a registry option so that plugins can register
# their own config files (or not) -- vila 20101002
- commands.Option('force', help='Force the configuration file',
- short_name='f', type=unicode),
+ commands.Option('scope', help='Reduce the scope to the specified'
+ ' configuration file',
+ type=unicode),
commands.Option('remove', help='Remove the option from'
' the configuration file'),
]
@commands.display_command
- def run(self, matching=None, directory=None, force=None, remove=False):
+ def run(self, matching=None, directory=None, scope=None, remove=False):
if directory is None:
directory = '.'
directory = urlutils.normalize_url(directory)
if matching is None:
- matching = '*'
self._show_config('*', directory)
else:
if remove:
- self._remove_config_option(matching, directory, force)
+ self._remove_config_option(matching, directory, scope)
else:
pos = matching.find('=')
if pos == -1:
self._show_config(matching, directory)
else:
self._set_config_option(matching[:pos], matching[pos+1:],
- directory, force)
+ directory, scope)
- def _get_configs(self, directory, force=None):
- """Iterate the configurations specified by ``directory`` and ``force``.
+ def _get_configs(self, directory, scope=None):
+ """Iterate the configurations specified by ``directory`` and ``scope``.
:param directory: Where the configurations are derived from.
- :param force: A specific config to start from.
+ :param scope: A specific config to start from.
"""
- if force is not None:
- if force == 'bazaar':
+ if scope is not None:
+ if scope == 'bazaar':
yield GlobalConfig()
- elif force == 'locations':
+ elif scope == 'locations':
yield LocationConfig(directory)
- elif force == 'branch':
+ elif scope == 'branch':
(_, br, _) = bzrdir.BzrDir.open_containing_tree_or_branch(
directory)
yield br.get_config()
@@ -1842,18 +1842,18 @@
cur_conf_id = conf_id
self.outf.write(' %s = %s\n' % (name, value))
- def _set_config_option(self, name, value, directory, force):
- for conf in self._get_configs(directory, force):
+ def _set_config_option(self, name, value, directory, scope):
+ for conf in self._get_configs(directory, scope):
conf.set_user_option(name, value)
break
else:
- raise errors.NoSuchConfig(force)
+ raise errors.NoSuchConfig(scope)
- def _remove_config_option(self, name, directory, force):
+ def _remove_config_option(self, name, directory, scope):
removed = False
- for conf in self._get_configs(directory, force):
+ for conf in self._get_configs(directory, scope):
for (section_name, section, conf_id) in conf._get_sections():
- if force is not None and conf_id != force:
+ if scope is not None and conf_id != scope:
# Not the right configuration file
continue
if name in section:
@@ -1866,6 +1866,6 @@
break
break
else:
- raise errors.NoSuchConfig(force)
+ raise errors.NoSuchConfig(scope)
if not removed:
raise errors.NoSuchConfigOption(name)
=== modified file 'bzrlib/tests/blackbox/test_config.py'
--- a/bzrlib/tests/blackbox/test_config.py 2010-10-04 17:24:52 +0000
+++ b/bzrlib/tests/blackbox/test_config.py 2010-10-13 14:14:37 +0000
@@ -88,11 +88,11 @@
def test_unknown_config(self):
self.run_bzr_error(['The "moon" configuration does not exist'],
- ['config', '--force', 'moon', 'hello=world'])
+ ['config', '--scope', 'moon', 'hello=world'])
def test_bazaar_config_outside_branch(self):
script.run_script(self, '''
-$ bzr config --force bazaar hello=world
+$ bzr config --scope bazaar hello=world
$ bzr config -d tree hello
bazaar:
hello = world
@@ -100,7 +100,7 @@
def test_bazaar_config_inside_branch(self):
script.run_script(self, '''
-$ bzr config -d tree --force bazaar hello=world
+$ bzr config -d tree --scope bazaar hello=world
$ bzr config -d tree hello
bazaar:
hello = world
@@ -108,7 +108,7 @@
def test_locations_config_inside_branch(self):
script.run_script(self, '''
-$ bzr config -d tree --force locations hello=world
+$ bzr config -d tree --scope locations hello=world
$ bzr config -d tree hello
locations:
hello = world
@@ -124,7 +124,7 @@
def test_branch_config_forcing_branch(self):
script.run_script(self, '''
-$ bzr config -d tree --force branch hello=world
+$ bzr config -d tree --scope branch hello=world
$ bzr config -d tree hello
branch:
hello = world
@@ -139,11 +139,11 @@
def test_unknown_config(self):
self.run_bzr_error(['The "moon" configuration does not exist'],
- ['config', '--force', 'moon', '--remove', 'file'])
+ ['config', '--scope', 'moon', '--remove', 'file'])
def test_bazaar_config_outside_branch(self):
script.run_script(self, '''
-$ bzr config --force bazaar --remove file
+$ bzr config --scope bazaar --remove file
$ bzr config -d tree file
locations:
file = locations
@@ -153,7 +153,7 @@
def test_bazaar_config_inside_branch(self):
script.run_script(self, '''
-$ bzr config -d tree --force bazaar --remove file
+$ bzr config -d tree --scope bazaar --remove file
$ bzr config -d tree file
locations:
file = locations
@@ -163,7 +163,7 @@
def test_locations_config_inside_branch(self):
script.run_script(self, '''
-$ bzr config -d tree --force locations --remove file
+$ bzr config -d tree --scope locations --remove file
$ bzr config -d tree file
branch:
file = branch
@@ -189,7 +189,7 @@
def test_branch_config_forcing_branch(self):
script.run_script(self, '''
-$ bzr config -d tree --force branch --remove file
+$ bzr config -d tree --scope branch --remove file
$ bzr config -d tree file
locations:
file = locations
More information about the bazaar-commits
mailing list