Rev 2619: Revert tightening of options api - breaks too many plugins in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Mon Jul 16 09:41:26 BST 2007
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 2619
revision-id: pqm at pqm.ubuntu.com-20070716084122-jfjzwtbimsjv0iqv
parent: pqm at pqm.ubuntu.com-20070715233134-zrptwn7og449cirw
parent: mbp at sourcefrog.net-20070713044155-3pifeyzn631q3tun
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2007-07-16 09:41:22 +0100
message:
Revert tightening of options api - breaks too many plugins
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/option.py option.py-20051014052914-661fb36e76e7362f
bzrlib/tests/test_options.py testoptions.py-20051014093702-96457cfc86319a8f
------------------------------------------------------------
revno: 2598.1.14
merged: mbp at sourcefrog.net-20070713044155-3pifeyzn631q3tun
parent: mbp at sourcefrog.net-20070713020421-1gwu8tzp7u9xd7kf
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: check-options
timestamp: Fri 2007-07-13 14:41:55 +1000
message:
Revert tightening of options api - breaks too many plugins
=== modified file 'NEWS'
--- a/NEWS 2007-07-13 06:12:27 +0000
+++ b/NEWS 2007-07-16 08:41:22 +0000
@@ -29,12 +29,9 @@
LIBRARY API BREAKS:
* Deprecated dictionary ``bzrlib.option.SHORT_OPTIONS`` removed.
- Various globally-declared options have been removed, so plugins
- that previously said ``takes_options=['message']`` must now
- construct an Option object and provide appropriate help. Options
- are now required to provide a help string and it must comply with
- the style guide by being one or more sentences with an initial
- capital and final period. (Martin Pool)
+ Options are now required to provide a help string and it must
+ comply with the style guide by being one or more sentences with an
+ initial capital and final period. (Martin Pool)
INTERNALS:
=== modified file 'bzrlib/option.py'
--- a/bzrlib/option.py 2007-07-11 05:18:42 +0000
+++ b/bzrlib/option.py 2007-07-13 04:41:55 +0000
@@ -367,26 +367,59 @@
_merge_type_registry.register_lazy('weave', 'bzrlib.merge', 'WeaveMerger',
"Weave-based merge")
+_global_option('all')
_global_option('overwrite', help='Ignore differences between branches and '
'overwrite unconditionally.')
+_global_option('basis', type=str)
+_global_option('bound')
+_global_option('diff-options', type=str)
+_global_option('file', type=unicode, short_name='F')
+_global_option('force')
+_global_option('format', type=unicode)
+_global_option('forward')
+_global_option('message', type=unicode,
+ short_name='m',
+ help='Message string.')
+_global_option('no-recurse')
+_global_option('profile',
+ help='Show performance profiling information.')
_global_option('revision',
type=_parse_revision_str,
short_name='r',
help='See \'help revisionspec\' for details.')
_global_option('show-ids',
help='Show internal object ids.')
+_global_option('timezone',
+ type=str,
+ help='display timezone as local, original, or utc')
+_global_option('unbound')
_global_option('verbose',
help='Display more information.',
short_name='v')
+_global_option('version')
+_global_option('email')
+_global_option('update')
_global_registry_option('log-format', "Use specified log format.",
log.log_formatter_registry, value_switches=True,
title='Log format')
+_global_option('long', help='Use detailed log format. Same as --log-format long',
+ short_name='l')
+_global_option('short', help='Use moderately short log format. Same as --log-format short')
+_global_option('line', help='Use log format with one line per revision. Same as --log-format line')
+_global_option('root', type=str)
+_global_option('no-backup')
_global_registry_option('merge-type', 'Select a particular merge algorithm.',
_merge_type_registry, value_switches=True,
title='Merge algorithm')
+_global_option('pattern', type=str)
+_global_option('quiet', short_name='q')
_global_option('remember', help='Remember the specified location as a'
' default.')
_global_option('reprocess', help='Reprocess to reduce spurious conflicts.')
+_global_option('kind', type=str)
+_global_option('dry-run',
+ help="Show what would be done, but don't actually do anything.")
+_global_option('name-from-revision', help='The path name in the old tree.')
_help_option = Option('help',
help='Show help message.',
=== modified file 'bzrlib/tests/test_options.py'
--- a/bzrlib/tests/test_options.py 2007-07-11 05:18:42 +0000
+++ b/bzrlib/tests/test_options.py 2007-07-13 04:41:55 +0000
@@ -241,27 +241,14 @@
class TestOptionDefinitions(TestCase):
"""Tests for options in the Bazaar codebase."""
- def get_all_options(self):
- """Return a list of all options used by Bazaar, both global and command.
-
- The list returned contains elements of (scope, option) where 'scope'
- is either None for global options, or a command name.
-
- This includes options provided by plugins.
- """
- g = [(None, opt) for name, opt
- in sorted(option.Option.OPTIONS.items())]
+ def get_builtin_command_options(self):
+ g = []
for cmd_name, cmd_class in sorted(commands.get_all_cmds()):
cmd = cmd_class()
for opt_name, opt in sorted(cmd.options().items()):
g.append((cmd_name, opt))
return g
- def test_get_all_options(self):
- all = self.get_all_options()
- self.assertTrue(len(all) > 100,
- "too few options found: %r" % all)
-
def test_global_options_used(self):
# In the distant memory, options could only be declared globally. Now
# we prefer to declare them in the command, unless like -r they really
@@ -281,12 +268,13 @@
else:
used_globals.setdefault(option_or_name, []).append(cmd_name)
unused_globals = set(g.keys()) - set(used_globals.keys())
- for option_name in sorted(unused_globals):
- msgs.append("unused global option %r" % option_name)
- for option_name, cmds in sorted(used_globals.items()):
- if len(cmds) <= 1:
- msgs.append("global option %r is only used by %r"
- % (option_name, cmds))
+ # not enforced because there might be plugins that use these globals
+ ## for option_name in sorted(unused_globals):
+ ## msgs.append("unused global option %r" % option_name)
+ ## for option_name, cmds in sorted(used_globals.items()):
+ ## if len(cmds) <= 1:
+ ## msgs.append("global option %r is only used by %r"
+ ## % (option_name, cmds))
if msgs:
self.fail("problems with global option definitions:\n"
+ '\n'.join(msgs))
@@ -297,7 +285,7 @@
# 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_all_options():
+ 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'))
@@ -307,7 +295,3 @@
if msgs:
self.fail("The following options don't match the style guide:\n"
+ '\n'.join(msgs))
-
- # TODO: Scan for global options that aren't used by any command?
- #
- # TODO: Check that there are two spaces between sentences.
More information about the bazaar-commits
mailing list