Rev 6166: Get rid of the --override-config long name, ensures the overrides are resest when the command has run. in file:///home/vila/src/bzr/bugs/491196-cmdline-options/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Thu Sep 29 13:54:10 UTC 2011
At file:///home/vila/src/bzr/bugs/491196-cmdline-options/
------------------------------------------------------------
revno: 6166
revision-id: v.ladeuil+lp at free.fr-20110929135410-gv714ay1lg6ttehv
parent: v.ladeuil+lp at free.fr-20110927131853-bafk1zx2zyv5otu1
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 491196-cmdline-options
timestamp: Thu 2011-09-29 15:54:10 +0200
message:
Get rid of the --override-config long name, ensures the overrides are resest when the command has run.
-------------- next part --------------
=== modified file 'bzrlib/commands.py'
--- a/bzrlib/commands.py 2011-09-27 13:18:53 +0000
+++ b/bzrlib/commands.py 2011-09-29 13:54:10 +0000
@@ -1070,9 +1070,6 @@
debug.debug_flags.add(a[2:])
elif a.startswith('-O'):
override_config.append(a[2:])
- elif a.startswith('--override-config'):
- i += 1
- override_config.append(argv[i])
else:
argv_copy.append(a)
i += 1
@@ -1136,6 +1133,8 @@
if 'memory' in debug.debug_flags:
trace.debug_memory('Process status after command:', short=False)
option._verbosity_level = saved_verbosity_level
+ # Reset the overrides
+ bzrlib.global_state.cmdline_overrides._reset()
def display_command(func):
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py 2011-09-27 13:18:53 +0000
+++ b/bzrlib/config.py 2011-09-29 13:54:10 +0000
@@ -2646,16 +2646,20 @@
class CommandLineSection(MutableSection):
- """A section used to carry command line option overrides."""
+ """A section used to carry command line overrides for the config options."""
def __init__(self, opts=None):
if opts is None:
opts = {}
super(CommandLineSection, self).__init__('cmdline-overrides', opts)
+ def _reset(self):
+ # The dict should be cleared but not replaced so it can be shared.
+ self.options.clear()
+
def _from_cmdline(self, overrides):
# Reset before accepting new definitions
- self.options.clear()
+ self._reset()
for over in overrides:
try:
name, value = over.split('=', 1)
=== modified file 'bzrlib/help_topics/__init__.py'
--- a/bzrlib/help_topics/__init__.py 2011-09-27 13:18:53 +0000
+++ b/bzrlib/help_topics/__init__.py 2011-09-29 13:54:10 +0000
@@ -312,27 +312,28 @@
These options may be used with any command, and may appear in front of any
command. (e.g. ``bzr --profile help``).
-
---version Print the version number. Must be supplied before the command.
---no-aliases Do not process command aliases when running this command.
---builtin Use the built-in version of a command, not the plugin version.
- This does not suppress other plugin effects.
---no-plugins Do not process any plugins.
---no-l10n Do not translate messages.
---concurrency Number of processes that can be run concurrently (selftest).
-
---profile Profile execution using the hotshot profiler.
---lsprof Profile execution using the lsprof profiler.
---lsprof-file Profile execution using the lsprof profiler, and write the
- results to a specified file. If the filename ends with
- ".txt", text format will be used. If the filename either
- starts with "callgrind.out" or end with ".callgrind", the
- output will be formatted for use with KCacheGrind. Otherwise,
- the output will be a pickle.
---coverage Generate line coverage report in the specified directory.
---override-config Override a config option for the duration of the command.
- This can be used multiple times if several options need to
- be overridden. The short form is ``-Oname=value``.
+
+--version Print the version number. Must be supplied before the command.
+--no-aliases Do not process command aliases when running this command.
+--builtin Use the built-in version of a command, not the plugin version.
+ This does not suppress other plugin effects.
+--no-plugins Do not process any plugins.
+--no-l10n Do not translate messages.
+--concurrency Number of processes that can be run concurrently (selftest).
+
+--profile Profile execution using the hotshot profiler.
+--lsprof Profile execution using the lsprof profiler.
+--lsprof-file Profile execution using the lsprof profiler, and write the
+ results to a specified file. If the filename ends with ".txt",
+ text format will be used. If the filename either starts with
+ "callgrind.out" or end with ".callgrind", the output will be
+ formatted for use with KCacheGrind. Otherwise, the output
+ will be a pickle.
+--coverage Generate line coverage report in the specified directory.
+
+-Oname=value Override the ``name`` config option setting it to ``value`` for
+ the duration of the command. This can be used multiple times if
+ several options need to be overridden.
See http://doc.bazaar.canonical.com/developers/profiling.html for more
information on profiling.
=== modified file 'bzrlib/tests/test_commands.py'
--- a/bzrlib/tests/test_commands.py 2011-09-27 13:18:53 +0000
+++ b/bzrlib/tests/test_commands.py 2011-09-29 13:54:10 +0000
@@ -44,12 +44,6 @@
commands_without_help.append(cmd_name)
self.assertLength(0, commands_without_help)
- def test_command_see_config_overrides(self):
- self.run_bzr(['rocks', '-Oxx=12', '--override-config', 'yy=foo'])
- c = config.GlobalStack()
- self.assertEquals('12', c.get('xx'))
- self.assertEquals('foo', c.get('yy'))
-
def test_display_command(self):
"""EPIPE message is selectively suppressed"""
def pipe_thrower():
@@ -97,6 +91,23 @@
self.assertContainsRe(c.get_help_text(), '--foo')
+class TestInsideCommand(tests.TestCaseInTempDir):
+
+ def test_command_see_config_overrides(self):
+ def run(cmd):
+ # We override the run() command method so we can observe the
+ # overrides from inside.
+ c = config.GlobalStack()
+ self.assertEquals('12', c.get('xx'))
+ self.assertEquals('foo', c.get('yy'))
+ self.overrideAttr(builtins.cmd_rocks, 'run', run)
+ self.run_bzr(['rocks', '-Oxx=12', '-Oyy=foo'])
+ c = config.GlobalStack()
+ # Ensure that we don't leak outside of the command
+ self.assertEquals(None, c.get('xx'))
+ self.assertEquals(None, c.get('yy'))
+
+
class TestInvokedAs(tests.TestCase):
def test_invoked_as(self):
=== modified file 'doc/en/release-notes/bzr-2.5.txt'
--- a/doc/en/release-notes/bzr-2.5.txt 2011-09-26 15:40:02 +0000
+++ b/doc/en/release-notes/bzr-2.5.txt 2011-09-29 13:54:10 +0000
@@ -20,11 +20,11 @@
.. New commands, options, etc that users may wish to try out.
-* A new ``--override-config`` (``-O`` for short) standard option (common to
- all commands) have been added. It provides a value for a config option in
- the ``-Oname=value`` form that takes precedence over all definitions found
- in config files. It can be used multiple times to override different
- options. (Vincent Ladeuil, #491196)
+* A new ``-O`` standard option (common to all commands) have been added. It
+ provides a value for a config option in the ``-Oname=value`` form that
+ takes precedence over all definitions found in config files. It can be
+ used multiple times to override different options.
+ (Vincent Ladeuil, #491196)
Improvements
************
More information about the bazaar-commits
mailing list