Rev 3670: (vila) Fix bug #263249 by setting valid default _param_name in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Mon Sep 1 09:31:13 BST 2008
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 3670
revision-id: pqm at pqm.ubuntu.com-20080901083105-x0h6ocy17ktfc9s4
parent: pqm at pqm.ubuntu.com-20080901065318-3r92nk175nbu54dw
parent: v.ladeuil+lp at free.fr-20080901075839-ts3l7ma47ubw2qht
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2008-09-01 09:31:05 +0100
message:
(vila) Fix bug #263249 by setting valid default _param_name
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/commands.py bzr.py-20050309040720-d10f4714595cf8c3
bzrlib/option.py option.py-20051014052914-661fb36e76e7362f
bzrlib/tests/test_options.py testoptions.py-20051014093702-96457cfc86319a8f
------------------------------------------------------------
revno: 3669.1.1
revision-id: v.ladeuil+lp at free.fr-20080901075839-ts3l7ma47ubw2qht
parent: pqm at pqm.ubuntu.com-20080901065318-3r92nk175nbu54dw
parent: v.ladeuil+lp at free.fr-20080831193901-q64gd8ekc3lyrjdl
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: trunk
timestamp: Mon 2008-09-01 09:58:39 +0200
message:
(vila) Fix bug #263249 by setting valid default _param_name
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/commands.py bzr.py-20050309040720-d10f4714595cf8c3
bzrlib/option.py option.py-20051014052914-661fb36e76e7362f
bzrlib/tests/test_options.py testoptions.py-20051014093702-96457cfc86319a8f
------------------------------------------------------------
revno: 3668.2.1
revision-id: v.ladeuil+lp at free.fr-20080831193901-q64gd8ekc3lyrjdl
parent: pqm at pqm.ubuntu.com-20080830091000-3oibqwlrxvdpgo5l
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 263249-list-option
timestamp: Sun 2008-08-31 21:39:01 +0200
message:
Fix bug #263249 by setting valid default _param_name.
* bzrlib/tests/test_options.py:
(TestListOptions.test_list_option_with_dash): Test that long list
options got valid _param_name.
* bzrlib/option.py:
(Option.__init__): Ensure that _param_name got a legal python
attribute name (as optparse do).
* bzrlib/commands.py:
(Command.get_help_text): Drive-by typo correction.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/commands.py bzr.py-20050309040720-d10f4714595cf8c3
bzrlib/option.py option.py-20051014052914-661fb36e76e7362f
bzrlib/tests/test_options.py testoptions.py-20051014093702-96457cfc86319a8f
=== modified file 'NEWS'
--- a/NEWS 2008-08-30 08:39:10 +0000
+++ b/NEWS 2008-08-31 19:39:01 +0000
@@ -53,7 +53,7 @@
* Merging from a previously joined branch will no longer cause
a traceback. (Jelmer Vernooij, #203376)
-
+
* Running ``bzr st PATH_TO_TREE`` will no longer suppress merge
status. Status is also about 7% faster on mozilla sized trees
when the path to the root of the tree has been given. Users of
@@ -61,6 +61,9 @@
the show_pending flag is now authoritative for showing pending
merges, as it was originally. (Robert Collins, #225204)
+ * Set valid default _param_name for Option so that ListOption can embed
+ '-' in names. (Vincent Ladeuil, #263249)
+
* ``WorkingTree4`` trees will now correctly report missing-and-new
paths in the output of ``iter_changes``. (Robert Collins)
=== modified file 'bzrlib/commands.py'
--- a/bzrlib/commands.py 2008-07-04 07:01:19 +0000
+++ b/bzrlib/commands.py 2008-08-31 19:39:01 +0000
@@ -366,7 +366,7 @@
result += ':See also: '
result += ', '.join(see_also) + '\n'
- # If this will be rendered as plan text, convert it
+ # If this will be rendered as plain text, convert it
if plain:
import bzrlib.help_topics
result = bzrlib.help_topics.help_as_plain_text(result)
@@ -389,7 +389,7 @@
sections[label] += '\n' + section
else:
sections[label] = section
-
+
lines = text.rstrip().splitlines()
summary = lines.pop(0)
sections = {}
@@ -497,7 +497,7 @@
self._setup_outf()
return self.run(**all_cmd_args)
-
+
def run(self):
"""Actually run the command.
=== modified file 'bzrlib/option.py'
--- a/bzrlib/option.py 2008-07-22 21:37:18 +0000
+++ b/bzrlib/option.py 2008-08-31 19:39:01 +0000
@@ -185,7 +185,7 @@
argname = 'ARG'
self.argname = argname
if param_name is None:
- self._param_name = self.name
+ self._param_name = self.name.replace('-', '_')
else:
self._param_name = param_name
self.custom_callback = custom_callback
@@ -210,22 +210,22 @@
option_strings.append('-%s' % short_name)
optargfn = self.type
if optargfn is None:
- parser.add_option(action='callback',
- callback=self._optparse_bool_callback,
+ parser.add_option(action='callback',
+ callback=self._optparse_bool_callback,
callback_args=(True,),
help=self.help,
*option_strings)
negation_strings = ['--%s' % self.get_negation_name()]
- parser.add_option(action='callback',
- callback=self._optparse_bool_callback,
+ parser.add_option(action='callback',
+ callback=self._optparse_bool_callback,
callback_args=(False,),
help=optparse.SUPPRESS_HELP, *negation_strings)
else:
- parser.add_option(action='callback',
- callback=self._optparse_callback,
+ parser.add_option(action='callback',
+ callback=self._optparse_callback,
type='string', metavar=self.argname.upper(),
help=self.help,
- default=OptionParser.DEFAULT_VALUE,
+ default=OptionParser.DEFAULT_VALUE,
*option_strings)
def _optparse_bool_callback(self, option, opt_str, value, parser, bool_v):
=== modified file 'bzrlib/tests/test_options.py'
--- a/bzrlib/tests/test_options.py 2008-08-05 00:43:28 +0000
+++ b/bzrlib/tests/test_options.py 2008-08-31 19:39:01 +0000
@@ -256,6 +256,12 @@
opts, args = self.parse(options, ['--hello=world', '--hello=sailor'])
self.assertEqual(['world', 'sailor'], opts.hello)
+ def test_list_option_with_dash(self):
+ options = [option.ListOption('with-dash', type=str)]
+ opts, args = self.parse(options, ['--with-dash=world',
+ '--with-dash=sailor'])
+ self.assertEqual(['world', 'sailor'], opts.with_dash)
+
def test_list_option_no_arguments(self):
options = [option.ListOption('hello', type=str)]
opts, args = self.parse(options, [])
More information about the bazaar-commits
mailing list