Rev 3756: Fix --verbose leaking into blackbox tests. in lp:~vila/bzr/cleanup.various/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Wed Oct 1 11:23:37 BST 2008
At lp:~vila/bzr/cleanup.various/
------------------------------------------------------------
revno: 3756
revision-id: v.ladeuil+lp at free.fr-20081001102336-unf0wqcvw51x8igr
parent: pqm at pqm.ubuntu.com-20081001064910-typ6d7diwd53z6iv
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: various
timestamp: Wed 2008-10-01 12:23:36 +0200
message:
Fix --verbose leaking into blackbox tests.
* bzrlib/commands.py:
(run_bzr): Save/restore verbosity_level to avoid leaks.
* bzrlib/tests/test_options.py:
(TestOptionDefinitions.test_option_grammar): Don't use 'option'
module name as a variable name.
* bzrlib/option.py:
(MergeTypeRegistry): Cleanup. This has been separated from the
related code by the '_verbosity_level' definition/code insertion.
(timezone): Respect style rules.
* bzrlib/builtins.py:
(cmd_log): Don't mask the global option for no good reason (or
should we delete the global option instead ?).
-------------- next part --------------
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2008-09-25 22:05:46 +0000
+++ b/bzrlib/builtins.py 2008-10-01 10:23:36 +0000
@@ -1682,9 +1682,7 @@
takes_options = [
Option('forward',
help='Show from oldest to newest.'),
- Option('timezone',
- type=str,
- help='Display timezone as local, original, or utc.'),
+ 'timezone',
custom_help('verbose',
help='Show files changed in each revision.'),
'show-ids',
=== modified file 'bzrlib/commands.py'
--- a/bzrlib/commands.py 2008-09-26 23:35:02 +0000
+++ b/bzrlib/commands.py 2008-10-01 10:23:36 +0000
@@ -675,9 +675,6 @@
def run_bzr(argv):
"""Execute a command.
- This is similar to main(), but without all the trappings for
- logging and error handling.
-
argv
The command-line arguments, without the program name from argv[0]
These should already be decoded. All library/test code calling
@@ -755,7 +752,7 @@
from bzrlib.builtins import cmd_version
cmd_version().run_argv_aliases([])
return 0
-
+
if not opt_no_plugins:
from bzrlib.plugin import load_plugins
load_plugins()
@@ -781,6 +778,10 @@
run_argv = [argv, alias_argv]
try:
+ # We can be called recursively (tests for example), but we don't want
+ # the verbosity level to propagate.
+ saved_verbosity_level = option._verbosity_level
+ option._verbosity_level = 0
if opt_lsprof:
if opt_coverage_dir:
trace.warning(
@@ -799,8 +800,10 @@
trace.debug_memory('Process status after command:', short=False)
return ret or 0
finally:
- # reset, in case we may do other commands later within the same process
- option._verbosity_level = 0
+ # reset, in case we may do other commands later within the same
+ # process. Commands that want to execute sub-commands must propagate
+ # --verbose in their own way.
+ option._verbosity_level = saved_verbosity_level
def display_command(func):
"""Decorator that suppresses pipe/interrupt errors."""
@@ -826,7 +829,7 @@
import bzrlib.ui
from bzrlib.ui.text import TextUIFactory
bzrlib.ui.ui_factory = TextUIFactory()
-
+
# Is this a final release version? If so, we should suppress warnings
if bzrlib.version_info[3] == 'final':
from bzrlib import symbol_versioning
=== modified file 'bzrlib/option.py'
--- a/bzrlib/option.py 2008-08-31 19:39:01 +0000
+++ b/bzrlib/option.py 2008-10-01 10:23:36 +0000
@@ -438,11 +438,6 @@
Option.OPTIONS[name] = RegistryOption(name, help, registry, **kwargs)
-class MergeTypeRegistry(registry.Registry):
-
- pass
-
-
# This is the verbosity level detected during command line parsing.
# Note that the final value is dependent on the order in which the
# various flags (verbose, quiet, no-verbose, no-quiet) are given.
@@ -471,6 +466,11 @@
_verbosity_level = -1
+class MergeTypeRegistry(registry.Registry):
+
+ pass
+
+
_merge_type_registry = MergeTypeRegistry()
_merge_type_registry.register_lazy('merge3', 'bzrlib.merge', 'Merge3Merger',
"Native diff3-style merge")
@@ -519,9 +519,9 @@
help='Select changes introduced by the specified revision. See also "help revisionspec".')
_global_option('show-ids',
help='Show internal object ids.')
-_global_option('timezone',
+_global_option('timezone',
type=str,
- help='display timezone as local, original, or utc')
+ help='Display timezone as local, original, or utc.')
_global_option('unbound')
_global_option('version')
_global_option('email')
=== modified file 'bzrlib/tests/test_options.py'
--- a/bzrlib/tests/test_options.py 2008-08-31 19:39:01 +0000
+++ b/bzrlib/tests/test_options.py 2008-10-01 10:23:36 +0000
@@ -353,13 +353,13 @@
# period and be all on a single line, because the display code will
# wrap it.
option_re = re.compile(r'^[A-Z][^\n]+\.$')
- for scope, option in self.get_builtin_command_options():
- if not option.help:
- msgs.append('%-16s %-16s %s' %
- ((scope or 'GLOBAL'), option.name, 'NO HELP'))
- elif not option_re.match(option.help):
- msgs.append('%-16s %-16s %s' %
- ((scope or 'GLOBAL'), option.name, option.help))
+ for scope, opt in self.get_builtin_command_options():
+ if not opt.help:
+ msgs.append('%-16s %-16s %s' %
+ ((scope or 'GLOBAL'), opt.name, 'NO HELP'))
+ elif not option_re.match(opt.help):
+ msgs.append('%-16s %-16s %s' %
+ ((scope or 'GLOBAL'), opt.name, opt.help))
if msgs:
self.fail("The following options don't match the style guide:\n"
+ '\n'.join(msgs))
More information about the bazaar-commits
mailing list