~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/option.py

  • Committer: Aaron Bentley
  • Date: 2007-01-17 15:39:21 UTC
  • mfrom: (1551.9.35 Aaron's mergeable stuff)
  • mto: This revision was merged to the branch mainline in revision 2239.
  • Revision ID: abentley@panoramicfeedback.com-20070117153921-6pp9ssa2r8n5izoo
Merge bzr.ab, to avoid conflicts submitting

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
from bzrlib import (
27
27
    errors,
28
28
    revisionspec,
 
29
    symbol_versioning,
29
30
    )
30
31
""")
31
32
from bzrlib.trace import warning
109
110
            (typestring, type_list)
110
111
        raise errors.BzrCommandError(msg)
111
112
 
 
113
 
112
114
class Option(object):
113
115
    """Description of a command line option
114
116
    
146
148
        self.argname = argname
147
149
 
148
150
    def short_name(self):
149
 
        return self._short_name
 
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
 
160
 
 
161
    def set_short_name(self, short_name):
 
162
        self._short_name = short_name
150
163
 
151
164
    def get_negation_name(self):
152
165
        if self.name.startswith('no-'):
265
278
_global_option('dry-run',
266
279
               help="show what would be done, but don't actually do anything")
267
280
_global_option('name-from-revision', help='The path name in the old tree.')
 
281
 
 
282
 
 
283
# prior to 0.14 these were always globally registered; the old dict is
 
284
# available for plugins that use it but it should not be used.
 
285
Option.SHORT_OPTIONS = symbol_versioning.DeprecatedDict(
 
286
    symbol_versioning.zero_fourteen,
 
287
    'SHORT_OPTIONS',
 
288
    {
 
289
        'F': Option.OPTIONS['file'],
 
290
        'h': Option.OPTIONS['help'],
 
291
        'm': Option.OPTIONS['message'],
 
292
        'r': Option.OPTIONS['revision'],
 
293
        'v': Option.OPTIONS['verbose'],
 
294
        'l': Option.OPTIONS['long'],
 
295
        'q': Option.OPTIONS['quiet'],
 
296
    },
 
297
    'Set the short option name when constructing the Option.',
 
298
    )