~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/option.py

  • Committer: Robert Collins
  • Date: 2005-10-17 11:56:54 UTC
  • mfrom: (1185.16.59)
  • Revision ID: robertc@robertcollins.net-20051017115654-662239e1587524a8
mergeĀ fromĀ martin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import bzrlib.commands
21
21
from bzrlib.trace import warning, mutter
22
22
from bzrlib.revisionspec import RevisionSpec
23
 
from bzrlib.errors import BzrCommandError
24
23
 
25
24
 
26
25
def _parse_revision_str(revstr):
103
102
 
104
103
 
105
104
def _parse_merge_type(typestring):
106
 
    return get_merge_type(typestring)
 
105
    return bzrlib.commands.get_merge_type(typestring)
107
106
 
108
 
def get_merge_type(typestring):
109
 
    """Attempt to find the merge class/factory associated with a string."""
110
 
    from merge import merge_types
111
 
    try:
112
 
        return merge_types[typestring][0]
113
 
    except KeyError:
114
 
        templ = '%s%%7s: %%s' % (' '*12)
115
 
        lines = [templ % (f[0], f[1][1]) for f in merge_types.iteritems()]
116
 
        type_list = '\n'.join(lines)
117
 
        msg = "No known merge type %s. Supported types are:\n%s" %\
118
 
            (typestring, type_list)
119
 
        raise BzrCommandError(msg)
120
107
 
121
108
class Option(object):
122
109
    """Description of a command line option"""
155
142
 
156
143
        Short options are globally registered.
157
144
        """
158
 
        for short, option in Option.SHORT_OPTIONS.iteritems():
159
 
            if option is self:
160
 
                return short
 
145
        return Option.SHORT_OPTIONS.get(self.name)
161
146
 
162
147
 
163
148
def _global_option(name, **kwargs):
165
150
    Option.OPTIONS[name] = Option(name, **kwargs)
166
151
 
167
152
_global_option('all')
168
 
_global_option('overwrite', help='Ignore differences between branches and '
169
 
               'overwrite unconditionally')
170
153
_global_option('basis', type=str)
171
154
_global_option('diff-options', type=str)
172
155
_global_option('help',
191
174
_global_option('version')
192
175
_global_option('email')
193
176
_global_option('update')
194
 
_global_option('long', help='Use detailed log format')
195
 
_global_option('short', help='Use moderately short log format')
196
 
_global_option('line', help='Use log format with one line per revision')
 
177
_global_option('long')
197
178
_global_option('root', type=str)
198
179
_global_option('no-backup')
199
180
_global_option('merge-type', type=_parse_merge_type)
200
181
_global_option('pattern', type=str)
201
182
_global_option('quiet')
202
 
_global_option('remember', help='Remember the specified location as a'
203
 
               ' default.')
204
 
_global_option('reprocess', help='Reprocess to reduce spurious conflicts')
205
 
_global_option('kind', type=str)
206
 
_global_option('dry-run',
207
 
               help="show what would be done, but don't actually do anything")
 
183
_global_option('remember')
208
184
 
209
185
 
210
186
def _global_short(short_name, long_name):