~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/option.py

[merge] robert's integration branch

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
23
24
 
24
25
 
25
26
def _parse_revision_str(revstr):
102
103
 
103
104
 
104
105
def _parse_merge_type(typestring):
105
 
    return bzrlib.commands.get_merge_type(typestring)
 
106
    return get_merge_type(typestring)
106
107
 
 
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)
107
120
 
108
121
class Option(object):
109
122
    """Description of a command line option"""
142
155
 
143
156
        Short options are globally registered.
144
157
        """
145
 
        return Option.SHORT_OPTIONS.get(self.name)
 
158
        for short, option in Option.SHORT_OPTIONS.iteritems():
 
159
            if option is self:
 
160
                return short
146
161
 
147
162
 
148
163
def _global_option(name, **kwargs):
150
165
    Option.OPTIONS[name] = Option(name, **kwargs)
151
166
 
152
167
_global_option('all')
153
 
_global_option('clobber')
 
168
_global_option('overwrite', help='Ignore differences between branches and '
 
169
               'overwrite unconditionally')
154
170
_global_option('basis', type=str)
155
171
_global_option('diff-options', type=str)
156
172
_global_option('help',
181
197
_global_option('merge-type', type=_parse_merge_type)
182
198
_global_option('pattern', type=str)
183
199
_global_option('quiet')
184
 
_global_option('remember')
 
200
_global_option('remember', help='Remember the specified location as a'
 
201
               ' default.')
 
202
_global_option('reprocess', help='Reprocess to reduce spurious conflicts')
185
203
 
186
204
 
187
205
def _global_short(short_name, long_name):