~bzr-pqm/bzr/bzr.dev

2052.3.2 by John Arbash Meinel
Change Copyright .. by Canonical to Copyright ... Canonical
1
# Copyright (C) 2004, 2005, 2006 Canonical Ltd
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
2
#
1185.16.41 by Martin Pool
[patch] define cli options as objects, not strings
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
7
#
1185.16.41 by Martin Pool
[patch] define cli options as objects, not strings
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
12
#
1185.16.41 by Martin Pool
[patch] define cli options as objects, not strings
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
1684.1.6 by Martin Pool
(patch) --diff-prefix option (goffredo, alexander)
17
# TODO: For things like --diff-prefix, we want a way to customize the display
18
# of the option argument.
1185.16.41 by Martin Pool
[patch] define cli options as objects, not strings
19
1996.3.28 by John Arbash Meinel
lazy import revisionspec and errors for bzrlib.options
20
import re
21
22
from bzrlib.lazy_import import lazy_import
23
lazy_import(globals(), """
1857.1.3 by Aaron Bentley
Make option adding depend on Option type
24
import optparse
1185.16.41 by Martin Pool
[patch] define cli options as objects, not strings
25
1996.3.28 by John Arbash Meinel
lazy import revisionspec and errors for bzrlib.options
26
from bzrlib import (
27
    errors,
28
    revisionspec,
2227.1.3 by mbp at sourcefrog
Restore access to SHORT_OPTIONS for compatibility
29
    symbol_versioning,
1996.3.28 by John Arbash Meinel
lazy import revisionspec and errors for bzrlib.options
30
    )
31
""")
1773.4.1 by Martin Pool
Add pyflakes makefile target; fix many warnings
32
from bzrlib.trace import warning
1185.16.41 by Martin Pool
[patch] define cli options as objects, not strings
33
34
35
def _parse_revision_str(revstr):
36
    """This handles a revision string -> revno.
37
38
    This always returns a list.  The list will have one element for
39
    each revision specifier supplied.
40
41
    >>> _parse_revision_str('234')
1948.4.31 by John Arbash Meinel
fix bugs in the test_annonate.py suite, which was passing '-r 3' as n argument not '-r3' or '-r', '3'
42
    [<RevisionSpec_revno 234>]
1185.16.41 by Martin Pool
[patch] define cli options as objects, not strings
43
    >>> _parse_revision_str('234..567')
1948.4.31 by John Arbash Meinel
fix bugs in the test_annonate.py suite, which was passing '-r 3' as n argument not '-r3' or '-r', '3'
44
    [<RevisionSpec_revno 234>, <RevisionSpec_revno 567>]
1185.16.41 by Martin Pool
[patch] define cli options as objects, not strings
45
    >>> _parse_revision_str('..')
46
    [<RevisionSpec None>, <RevisionSpec None>]
47
    >>> _parse_revision_str('..234')
1948.4.31 by John Arbash Meinel
fix bugs in the test_annonate.py suite, which was passing '-r 3' as n argument not '-r3' or '-r', '3'
48
    [<RevisionSpec None>, <RevisionSpec_revno 234>]
1185.16.41 by Martin Pool
[patch] define cli options as objects, not strings
49
    >>> _parse_revision_str('234..')
1948.4.31 by John Arbash Meinel
fix bugs in the test_annonate.py suite, which was passing '-r 3' as n argument not '-r3' or '-r', '3'
50
    [<RevisionSpec_revno 234>, <RevisionSpec None>]
1185.16.41 by Martin Pool
[patch] define cli options as objects, not strings
51
    >>> _parse_revision_str('234..456..789') # Maybe this should be an error
1948.4.31 by John Arbash Meinel
fix bugs in the test_annonate.py suite, which was passing '-r 3' as n argument not '-r3' or '-r', '3'
52
    [<RevisionSpec_revno 234>, <RevisionSpec_revno 456>, <RevisionSpec_revno 789>]
1185.16.41 by Martin Pool
[patch] define cli options as objects, not strings
53
    >>> _parse_revision_str('234....789') #Error ?
1948.4.31 by John Arbash Meinel
fix bugs in the test_annonate.py suite, which was passing '-r 3' as n argument not '-r3' or '-r', '3'
54
    [<RevisionSpec_revno 234>, <RevisionSpec None>, <RevisionSpec_revno 789>]
1185.16.41 by Martin Pool
[patch] define cli options as objects, not strings
55
    >>> _parse_revision_str('revid:test@other.com-234234')
56
    [<RevisionSpec_revid revid:test@other.com-234234>]
57
    >>> _parse_revision_str('revid:test@other.com-234234..revid:test@other.com-234235')
58
    [<RevisionSpec_revid revid:test@other.com-234234>, <RevisionSpec_revid revid:test@other.com-234235>]
59
    >>> _parse_revision_str('revid:test@other.com-234234..23')
1948.4.31 by John Arbash Meinel
fix bugs in the test_annonate.py suite, which was passing '-r 3' as n argument not '-r3' or '-r', '3'
60
    [<RevisionSpec_revid revid:test@other.com-234234>, <RevisionSpec_revno 23>]
1185.16.41 by Martin Pool
[patch] define cli options as objects, not strings
61
    >>> _parse_revision_str('date:2005-04-12')
62
    [<RevisionSpec_date date:2005-04-12>]
63
    >>> _parse_revision_str('date:2005-04-12 12:24:33')
64
    [<RevisionSpec_date date:2005-04-12 12:24:33>]
65
    >>> _parse_revision_str('date:2005-04-12T12:24:33')
66
    [<RevisionSpec_date date:2005-04-12T12:24:33>]
67
    >>> _parse_revision_str('date:2005-04-12,12:24:33')
68
    [<RevisionSpec_date date:2005-04-12,12:24:33>]
69
    >>> _parse_revision_str('-5..23')
1948.4.31 by John Arbash Meinel
fix bugs in the test_annonate.py suite, which was passing '-r 3' as n argument not '-r3' or '-r', '3'
70
    [<RevisionSpec_revno -5>, <RevisionSpec_revno 23>]
1185.16.41 by Martin Pool
[patch] define cli options as objects, not strings
71
    >>> _parse_revision_str('-5')
1948.4.31 by John Arbash Meinel
fix bugs in the test_annonate.py suite, which was passing '-r 3' as n argument not '-r3' or '-r', '3'
72
    [<RevisionSpec_revno -5>]
1185.16.41 by Martin Pool
[patch] define cli options as objects, not strings
73
    >>> _parse_revision_str('123a')
74
    Traceback (most recent call last):
75
      ...
1948.4.32 by John Arbash Meinel
Clean up __repr__, as well as add tests that we can handle -r12:branch/
76
    NoSuchRevisionSpec: No namespace registered for string: '123a'
1185.16.41 by Martin Pool
[patch] define cli options as objects, not strings
77
    >>> _parse_revision_str('abc')
78
    Traceback (most recent call last):
79
      ...
1948.4.32 by John Arbash Meinel
Clean up __repr__, as well as add tests that we can handle -r12:branch/
80
    NoSuchRevisionSpec: No namespace registered for string: 'abc'
1185.16.41 by Martin Pool
[patch] define cli options as objects, not strings
81
    >>> _parse_revision_str('branch:../branch2')
82
    [<RevisionSpec_branch branch:../branch2>]
1545.1.1 by Denys Duchier
distinguish ../ as path to branch and .. as revspec separator
83
    >>> _parse_revision_str('branch:../../branch2')
84
    [<RevisionSpec_branch branch:../../branch2>]
85
    >>> _parse_revision_str('branch:../../branch2..23')
1948.4.31 by John Arbash Meinel
fix bugs in the test_annonate.py suite, which was passing '-r 3' as n argument not '-r3' or '-r', '3'
86
    [<RevisionSpec_branch branch:../../branch2>, <RevisionSpec_revno 23>]
1185.16.41 by Martin Pool
[patch] define cli options as objects, not strings
87
    """
88
    # TODO: Maybe move this into revisionspec.py
89
    revs = []
1988.4.5 by Robert Collins
revisions can now be specified using dotted-decimal revision numbers.
90
    # split on the first .. that is not followed by a / ?
1948.4.28 by John Arbash Meinel
Remove some places that were directly instantiating a RevisionSpec object. Also get rid of support for --revision 1:2, it has been deprecated for a long time
91
    sep = re.compile("\\.\\.(?!/)")
92
    for x in sep.split(revstr):
1996.3.28 by John Arbash Meinel
lazy import revisionspec and errors for bzrlib.options
93
        revs.append(revisionspec.RevisionSpec.from_string(x or None))
1185.16.41 by Martin Pool
[patch] define cli options as objects, not strings
94
    return revs
95
96
97
def _parse_merge_type(typestring):
1185.12.62 by Aaron Bentley
Restored merge-type selection
98
    return get_merge_type(typestring)
1185.16.41 by Martin Pool
[patch] define cli options as objects, not strings
99
1185.12.62 by Aaron Bentley
Restored merge-type selection
100
def get_merge_type(typestring):
101
    """Attempt to find the merge class/factory associated with a string."""
102
    from merge import merge_types
103
    try:
104
        return merge_types[typestring][0]
105
    except KeyError:
106
        templ = '%s%%7s: %%s' % (' '*12)
107
        lines = [templ % (f[0], f[1][1]) for f in merge_types.iteritems()]
108
        type_list = '\n'.join(lines)
109
        msg = "No known merge type %s. Supported types are:\n%s" %\
110
            (typestring, type_list)
1996.3.28 by John Arbash Meinel
lazy import revisionspec and errors for bzrlib.options
111
        raise errors.BzrCommandError(msg)
1185.16.41 by Martin Pool
[patch] define cli options as objects, not strings
112
2227.1.2 by mbp at sourcefrog
Add a simple DeprecatedDict class
113
1185.16.41 by Martin Pool
[patch] define cli options as objects, not strings
114
class Option(object):
2190.2.1 by Martin Pool
remove global registration of short options
115
    """Description of a command line option
116
    
2227.1.1 by mbp at sourcefrog
Back out previous incompatible change: Option.short_name is now again
117
    :ivar _short_name: If this option has a single-letter name, this is it.
2190.2.1 by Martin Pool
remove global registration of short options
118
    Otherwise None.
119
    """
120
1185.16.45 by Martin Pool
- refactor handling of short option names
121
    # TODO: Some way to show in help a description of the option argument
122
1185.16.41 by Martin Pool
[patch] define cli options as objects, not strings
123
    OPTIONS = {}
124
2190.2.1 by Martin Pool
remove global registration of short options
125
    def __init__(self, name, help='', type=None, argname=None,
126
                 short_name=None):
1185.16.45 by Martin Pool
- refactor handling of short option names
127
        """Make a new command option.
128
129
        name -- regular name of the command, used in the double-dash
130
            form and also as the parameter to the command's run() 
131
            method.
132
133
        help -- help message displayed in command help
134
135
        type -- function called to parse the option argument, or 
136
            None (default) if this option doesn't take an argument.
1185.16.48 by mbp at sourcefrog
- more refactoring of and tests for option parsing
137
138
        argname -- name of option argument, if any
1185.16.45 by Martin Pool
- refactor handling of short option names
139
        """
1185.16.41 by Martin Pool
[patch] define cli options as objects, not strings
140
        self.name = name
141
        self.help = help
142
        self.type = type
2227.1.1 by mbp at sourcefrog
Back out previous incompatible change: Option.short_name is now again
143
        self._short_name = short_name
1185.16.48 by mbp at sourcefrog
- more refactoring of and tests for option parsing
144
        if type is None:
145
            assert argname is None
146
        elif argname is None:
147
            argname = 'ARG'
148
        self.argname = argname
1185.16.41 by Martin Pool
[patch] define cli options as objects, not strings
149
2227.1.1 by mbp at sourcefrog
Back out previous incompatible change: Option.short_name is now again
150
    def short_name(self):
2227.1.3 by mbp at sourcefrog
Restore access to SHORT_OPTIONS for compatibility
151
        if self._short_name:
152
            return self._short_name
153
        else:
154
            # remove this when SHORT_OPTIONS is removed
155
            # XXX: This is accessing a DeprecatedDict, so we call the super 
156
            # method to avoid warnings
157
            for (k, v) in dict.iteritems(Option.SHORT_OPTIONS):
158
                if v == self:
159
                    return k
2227.1.1 by mbp at sourcefrog
Back out previous incompatible change: Option.short_name is now again
160
2227.1.4 by mbp at sourcefrog
add test that legacy SHORT_OPTIONS really works, and set_short_name
161
    def set_short_name(self, short_name):
162
        self._short_name = short_name
163
1857.1.9 by Aaron Bentley
Add hidden negation options
164
    def get_negation_name(self):
165
        if self.name.startswith('no-'):
166
            return self.name[3:]
167
        else:
168
            return 'no-' + self.name
169
1857.1.3 by Aaron Bentley
Make option adding depend on Option type
170
    def add_option(self, parser, short_name):
171
        """Add this option to an Optparse parser"""
172
        option_strings = ['--%s' % self.name]
173
        if short_name is not None:
174
            option_strings.append('-%s' % short_name)
175
        optargfn = self.type
176
        if optargfn is None:
177
            parser.add_option(action='store_true', dest=self.name, 
178
                              help=self.help,
179
                              default=OptionParser.DEFAULT_VALUE,
180
                              *option_strings)
1857.1.9 by Aaron Bentley
Add hidden negation options
181
            negation_strings = ['--%s' % self.get_negation_name()]
1857.1.22 by Aaron Bentley
Negations set value to False, instead of Optparser.DEFAULT_VALUE
182
            parser.add_option(action='store_false', dest=self.name, 
183
                              help=optparse.SUPPRESS_HELP, *negation_strings)
1857.1.3 by Aaron Bentley
Make option adding depend on Option type
184
        else:
185
            parser.add_option(action='callback', 
186
                              callback=self._optparse_callback, 
1857.1.12 by Aaron Bentley
Fix a bunch of test cases that assumed --merge-type or log-format
187
                              type='string', metavar=self.argname.upper(),
1857.1.4 by Aaron Bentley
Set metavar according to option
188
                              help=self.help,
1857.1.3 by Aaron Bentley
Make option adding depend on Option type
189
                              default=OptionParser.DEFAULT_VALUE, 
190
                              *option_strings)
191
192
    def _optparse_callback(self, option, opt, value, parser):
193
        setattr(parser.values, self.name, self.type(value))
194
1857.1.14 by Aaron Bentley
Fix man page generation
195
    def iter_switches(self):
196
        """Iterate through the list of switches provided by the option
197
        
198
        :return: an iterator of (name, short_name, argname, help)
199
        """
200
        argname =  self.argname
201
        if argname is not None:
202
            argname = argname.upper()
2227.1.1 by mbp at sourcefrog
Back out previous incompatible change: Option.short_name is now again
203
        yield self.name, self.short_name(), argname, self.help
1857.1.3 by Aaron Bentley
Make option adding depend on Option type
204
1857.1.15 by Aaron Bentley
Add tests for generating an option parser
205
2221.4.1 by Aaron Bentley
Get registry options working
206
class RegistryOption(Option):
2221.4.6 by Aaron Bentley
Improve text and naming
207
    """Option based on a registry
2221.4.9 by Aaron Bentley
Zap trailing whitespace
208
2221.4.6 by Aaron Bentley
Improve text and naming
209
    The values for the options correspond to entries in the registry.  Input
210
    must be a registry key.  After validation, it is converted into an object
211
    using Registry.get or a caller-provided converter.
212
    """
2221.4.1 by Aaron Bentley
Get registry options working
213
214
    def validate_value(self, value):
2221.4.3 by Aaron Bentley
Add docstrings
215
        """Validate a value name"""
2221.4.1 by Aaron Bentley
Get registry options working
216
        if value not in self.registry:
2221.4.6 by Aaron Bentley
Improve text and naming
217
            raise errors.BadOptionValue(self.name, value)
2221.4.1 by Aaron Bentley
Get registry options working
218
2221.4.2 by Aaron Bentley
Implement RegistryOption on init
219
    def convert(self, value):
2221.4.3 by Aaron Bentley
Add docstrings
220
        """Convert a value name into an output type"""
221
        self.validate_value(value)
2221.4.1 by Aaron Bentley
Get registry options working
222
        if self.converter is None:
2221.4.2 by Aaron Bentley
Implement RegistryOption on init
223
            return self.registry.get(value)
2221.4.1 by Aaron Bentley
Get registry options working
224
        else:
2221.4.2 by Aaron Bentley
Implement RegistryOption on init
225
            return self.converter(value)
2221.4.1 by Aaron Bentley
Get registry options working
226
2221.4.2 by Aaron Bentley
Implement RegistryOption on init
227
    def __init__(self, name, help, registry, converter=None,
228
        value_switches=False):
2221.4.3 by Aaron Bentley
Add docstrings
229
        """
230
        Constructor.
231
232
        :param name: The option name.
233
        :param help: Help for the option.
234
        :param registry: A Registry containing the values
235
        :param converter: Callable to invoke with the value name to produce
2221.4.6 by Aaron Bentley
Improve text and naming
236
            the value.  If not supplied, self.registry.get is used.
2221.4.3 by Aaron Bentley
Add docstrings
237
        :param value_switches: If true, each possible value is assigned its
2221.4.9 by Aaron Bentley
Zap trailing whitespace
238
            own switch.  For example, instead of '--format metaweave',
2221.4.3 by Aaron Bentley
Add docstrings
239
            '--metaweave' can be used interchangeably.
240
        """
241
        Option.__init__(self, name, help, type=self.convert)
2221.4.1 by Aaron Bentley
Get registry options working
242
        self.registry = registry
243
        self.name = name
244
        self.converter = converter
2221.4.2 by Aaron Bentley
Implement RegistryOption on init
245
        self.value_switches = value_switches
2221.4.1 by Aaron Bentley
Get registry options working
246
247
    def add_option(self, parser, short_name):
248
        """Add this option to an Optparse parser"""
249
        Option.add_option(self, parser, short_name)
250
        if self.value_switches:
251
            for key in self.registry.keys():
252
                option_strings = ['--%s' % key]
2221.4.9 by Aaron Bentley
Zap trailing whitespace
253
                parser.add_option(action='callback',
254
                              callback=self._optparse_value_callback(key),
2221.4.2 by Aaron Bentley
Implement RegistryOption on init
255
                                  help=self.registry.get_help(key),
2221.4.1 by Aaron Bentley
Get registry options working
256
                                  *option_strings)
257
258
    def _optparse_value_callback(self, cb_value):
259
        def cb(option, opt, value, parser):
260
            setattr(parser.values, self.name, self.type(cb_value))
261
        return cb
262
2221.4.4 by Aaron Bentley
Fix iter_switches behavior when value_switches is true
263
    def iter_switches(self):
264
        """Iterate through the list of switches provided by the option
2221.4.9 by Aaron Bentley
Zap trailing whitespace
265
2221.4.4 by Aaron Bentley
Fix iter_switches behavior when value_switches is true
266
        :return: an iterator of (name, short_name, argname, help)
267
        """
268
        for value in Option.iter_switches(self):
269
            yield value
270
        if self.value_switches:
271
            for key in sorted(self.registry.keys()):
272
                yield key, None, None, self.registry.get_help(key)
2221.4.1 by Aaron Bentley
Get registry options working
273
2221.4.6 by Aaron Bentley
Improve text and naming
274
1857.1.3 by Aaron Bentley
Make option adding depend on Option type
275
class OptionParser(optparse.OptionParser):
276
    """OptionParser that raises exceptions instead of exiting"""
277
1857.1.6 by Aaron Bentley
Make the DEFAULT_VALUE an object instance
278
    DEFAULT_VALUE = object()
1857.1.3 by Aaron Bentley
Make option adding depend on Option type
279
280
    def error(self, message):
1996.3.28 by John Arbash Meinel
lazy import revisionspec and errors for bzrlib.options
281
        raise errors.BzrCommandError(message)
1857.1.3 by Aaron Bentley
Make option adding depend on Option type
282
283
284
def get_optparser(options):
285
    """Generate an optparse parser for bzrlib-style options"""
286
287
    parser = OptionParser()
288
    parser.remove_option('--help')
289
    for option in options.itervalues():
2227.1.1 by mbp at sourcefrog
Back out previous incompatible change: Option.short_name is now again
290
        option.add_option(parser, option.short_name())
1857.1.3 by Aaron Bentley
Make option adding depend on Option type
291
    return parser
292
1185.16.45 by Martin Pool
- refactor handling of short option names
293
1185.16.41 by Martin Pool
[patch] define cli options as objects, not strings
294
def _global_option(name, **kwargs):
295
    """Register o as a global option."""
296
    Option.OPTIONS[name] = Option(name, **kwargs)
297
1185.16.45 by Martin Pool
- refactor handling of short option names
298
_global_option('all')
1185.12.92 by Aaron Bentley
Fixed pull help, renamed clobber to overwrite
299
_global_option('overwrite', help='Ignore differences between branches and '
300
               'overwrite unconditionally')
1185.16.41 by Martin Pool
[patch] define cli options as objects, not strings
301
_global_option('basis', type=str)
1505.1.2 by John Arbash Meinel
(broken) working on implementing bound branches.
302
_global_option('bound')
1185.16.41 by Martin Pool
[patch] define cli options as objects, not strings
303
_global_option('diff-options', type=str)
1185.16.55 by mbp at sourcefrog
- more option help
304
_global_option('help',
2190.2.1 by Martin Pool
remove global registration of short options
305
               help='show help message',
306
               short_name='h')
307
_global_option('file', type=unicode, short_name='F')
1185.16.45 by Martin Pool
- refactor handling of short option names
308
_global_option('force')
1185.16.41 by Martin Pool
[patch] define cli options as objects, not strings
309
_global_option('format', type=unicode)
1185.16.45 by Martin Pool
- refactor handling of short option names
310
_global_option('forward')
2190.2.1 by Martin Pool
remove global registration of short options
311
_global_option('message', type=unicode,
312
               short_name='m')
1185.16.45 by Martin Pool
- refactor handling of short option names
313
_global_option('no-recurse')
1185.16.55 by mbp at sourcefrog
- more option help
314
_global_option('profile',
315
               help='show performance profiling information')
2204.2.1 by Wouter van Heyst
Fix merge conflicts.
316
_global_option('revision',
2190.2.1 by Martin Pool
remove global registration of short options
317
               type=_parse_revision_str,
2204.2.1 by Wouter van Heyst
Fix merge conflicts.
318
               short_name='r',
2201.2.1 by Wouter van Heyst
Make mention of the revisionspec topic in the revision option help (#31633).
319
               help='See \'help revisionspec\' for details')
1185.16.47 by Martin Pool
- help for global options
320
_global_option('show-ids', 
321
               help='show internal object ids')
1185.16.48 by mbp at sourcefrog
- more refactoring of and tests for option parsing
322
_global_option('timezone', 
323
               type=str,
324
               help='display timezone as local, original, or utc')
1505.1.2 by John Arbash Meinel
(broken) working on implementing bound branches.
325
_global_option('unbound')
1185.16.48 by mbp at sourcefrog
- more refactoring of and tests for option parsing
326
_global_option('verbose',
2190.2.1 by Martin Pool
remove global registration of short options
327
               help='display more information',
328
               short_name='v')
1185.16.45 by Martin Pool
- refactor handling of short option names
329
_global_option('version')
330
_global_option('email')
331
_global_option('update')
1857.1.20 by Aaron Bentley
Strip out all the EnumOption stuff
332
_global_option('log-format', type=str, help="Use this log format")
2190.2.1 by Martin Pool
remove global registration of short options
333
_global_option('long', help='Use detailed log format. Same as --log-format long',
334
               short_name='l')
1857.1.20 by Aaron Bentley
Strip out all the EnumOption stuff
335
_global_option('short', help='Use moderately short log format. Same as --log-format short')
336
_global_option('line', help='Use log format with one line per revision. Same as --log-format line')
1185.16.41 by Martin Pool
[patch] define cli options as objects, not strings
337
_global_option('root', type=str)
1185.16.45 by Martin Pool
- refactor handling of short option names
338
_global_option('no-backup')
1857.1.20 by Aaron Bentley
Strip out all the EnumOption stuff
339
_global_option('merge-type', type=_parse_merge_type, 
340
               help='Select a particular merge algorithm')
1185.16.41 by Martin Pool
[patch] define cli options as objects, not strings
341
_global_option('pattern', type=str)
2190.2.1 by Martin Pool
remove global registration of short options
342
_global_option('quiet', short_name='q')
1185.12.92 by Aaron Bentley
Fixed pull help, renamed clobber to overwrite
343
_global_option('remember', help='Remember the specified location as a'
344
               ' default.')
1185.24.3 by Aaron Bentley
Integrated reprocessing into the rest of the merge stuff
345
_global_option('reprocess', help='Reprocess to reduce spurious conflicts')
1185.33.33 by Martin Pool
[patch] add 'bzr inventory --kind directory'; remove 'bzr directories'
346
_global_option('kind', type=str)
1185.33.90 by Martin Pool
[merge] add --dry-run option (mpe)
347
_global_option('dry-run',
348
               help="show what would be done, but don't actually do anything")
2073.2.3 by wang
Change option name to --name-from-revision. Always make new tree the
349
_global_option('name-from-revision', help='The path name in the old tree.')
2227.1.3 by mbp at sourcefrog
Restore access to SHORT_OPTIONS for compatibility
350
351
352
# prior to 0.14 these were always globally registered; the old dict is
353
# available for plugins that use it but it should not be used.
354
Option.SHORT_OPTIONS = symbol_versioning.DeprecatedDict(
355
    symbol_versioning.zero_fourteen,
356
    'SHORT_OPTIONS',
357
    {
358
        'F': Option.OPTIONS['file'],
359
        'h': Option.OPTIONS['help'],
360
        'm': Option.OPTIONS['message'],
361
        'r': Option.OPTIONS['revision'],
362
        'v': Option.OPTIONS['verbose'],
363
        'l': Option.OPTIONS['long'],
364
        'q': Option.OPTIONS['quiet'],
365
    },
366
    'Set the short option name when constructing the Option.',
367
    )