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
25
26
def _parse_revision_str(revstr):
70
71
BzrError: No namespace registered for string: 'abc'
71
72
>>> _parse_revision_str('branch:../branch2')
72
73
[<RevisionSpec_branch branch:../branch2>]
74
>>> _parse_revision_str('branch:../../branch2')
75
[<RevisionSpec_branch branch:../../branch2>]
76
>>> _parse_revision_str('branch:../../branch2..23')
77
[<RevisionSpec_branch branch:../../branch2>, <RevisionSpec_int 23>]
74
79
# TODO: Maybe move this into revisionspec.py
75
80
old_format_re = re.compile('\d*:\d*')
85
90
revs.append(RevisionSpec(None))
88
for x in revstr.split('..'):
90
revs.append(RevisionSpec(None))
92
# looks like a namespace:.. has happened
93
next_prefix = x + '..'
95
if next_prefix is not None:
97
revs.append(RevisionSpec(x))
99
if next_prefix is not None:
100
revs.append(RevisionSpec(next_prefix))
92
sep = re.compile("\\.\\.(?!/)")
93
for x in sep.split(revstr):
94
revs.append(RevisionSpec(x or None))
104
98
def _parse_merge_type(typestring):
105
return bzrlib.commands.get_merge_type(typestring)
99
return get_merge_type(typestring)
101
def get_merge_type(typestring):
102
"""Attempt to find the merge class/factory associated with a string."""
103
from merge import merge_types
105
return merge_types[typestring][0]
107
templ = '%s%%7s: %%s' % (' '*12)
108
lines = [templ % (f[0], f[1][1]) for f in merge_types.iteritems()]
109
type_list = '\n'.join(lines)
110
msg = "No known merge type %s. Supported types are:\n%s" %\
111
(typestring, type_list)
112
raise BzrCommandError(msg)
108
114
class Option(object):
109
115
"""Description of a command line option"""
143
149
Short options are globally registered.
145
return Option.SHORT_OPTIONS.get(self.name)
151
for short, option in Option.SHORT_OPTIONS.iteritems():
148
156
def _global_option(name, **kwargs):
150
158
Option.OPTIONS[name] = Option(name, **kwargs)
152
160
_global_option('all')
153
_global_option('clobber')
161
_global_option('overwrite', help='Ignore differences between branches and '
162
'overwrite unconditionally')
154
163
_global_option('basis', type=str)
164
_global_option('bound')
155
165
_global_option('diff-options', type=str)
156
166
_global_option('help',
157
167
help='show help message')
170
180
_global_option('timezone',
172
182
help='display timezone as local, original, or utc')
183
_global_option('unbound')
173
184
_global_option('verbose',
174
185
help='display more information')
175
186
_global_option('version')
176
187
_global_option('email')
177
188
_global_option('update')
178
_global_option('long')
189
_global_option('log-format', type=str, help="Use this log format")
190
_global_option('long', help='Use detailed log format. Same as --log-format long')
191
_global_option('short', help='Use moderately short log format. Same as --log-format short')
192
_global_option('line', help='Use log format with one line per revision. Same as --log-format line')
179
193
_global_option('root', type=str)
180
194
_global_option('no-backup')
181
195
_global_option('merge-type', type=_parse_merge_type)
182
196
_global_option('pattern', type=str)
183
197
_global_option('quiet')
184
_global_option('remember')
198
_global_option('remember', help='Remember the specified location as a'
200
_global_option('reprocess', help='Reprocess to reduce spurious conflicts')
201
_global_option('kind', type=str)
202
_global_option('dry-run',
203
help="show what would be done, but don't actually do anything")
187
206
def _global_short(short_name, long_name):