1
# Copyright (C) 2004, 2005 by Canonical Ltd
1
# Copyright (C) 2004, 2005, 2006 by Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
# TODO: For things like --diff-prefix, we want a way to customize the display
18
# of the option argument.
20
22
import bzrlib.commands
21
23
from bzrlib.trace import warning, mutter
22
24
from bzrlib.revisionspec import RevisionSpec
25
from bzrlib.errors import BzrCommandError
25
28
def _parse_revision_str(revstr):
70
73
BzrError: No namespace registered for string: 'abc'
71
74
>>> _parse_revision_str('branch:../branch2')
72
75
[<RevisionSpec_branch branch:../branch2>]
76
>>> _parse_revision_str('branch:../../branch2')
77
[<RevisionSpec_branch branch:../../branch2>]
78
>>> _parse_revision_str('branch:../../branch2..23')
79
[<RevisionSpec_branch branch:../../branch2>, <RevisionSpec_int 23>]
74
81
# TODO: Maybe move this into revisionspec.py
75
82
old_format_re = re.compile('\d*:\d*')
85
92
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))
94
sep = re.compile("\\.\\.(?!/)")
95
for x in sep.split(revstr):
96
revs.append(RevisionSpec(x or None))
104
100
def _parse_merge_type(typestring):
105
return bzrlib.commands.get_merge_type(typestring)
101
return get_merge_type(typestring)
103
def get_merge_type(typestring):
104
"""Attempt to find the merge class/factory associated with a string."""
105
from merge import merge_types
107
return merge_types[typestring][0]
109
templ = '%s%%7s: %%s' % (' '*12)
110
lines = [templ % (f[0], f[1][1]) for f in merge_types.iteritems()]
111
type_list = '\n'.join(lines)
112
msg = "No known merge type %s. Supported types are:\n%s" %\
113
(typestring, type_list)
114
raise BzrCommandError(msg)
108
116
class Option(object):
109
117
"""Description of a command line option"""
150
160
Option.OPTIONS[name] = Option(name, **kwargs)
152
162
_global_option('all')
153
_global_option('clobber')
163
_global_option('overwrite', help='Ignore differences between branches and '
164
'overwrite unconditionally')
154
165
_global_option('basis', type=str)
166
_global_option('bound')
155
167
_global_option('diff-options', type=str)
156
168
_global_option('help',
157
169
help='show help message')
161
173
_global_option('forward')
162
174
_global_option('message', type=unicode)
163
175
_global_option('no-recurse')
176
_global_option('prefix', type=str,
177
help='Set prefixes to added to old and new filenames, as '
178
'two values separated by a colon.')
164
179
_global_option('profile',
165
180
help='show performance profiling information')
166
181
_global_option('revision', type=_parse_revision_str)
167
_global_option('short')
168
182
_global_option('show-ids',
169
183
help='show internal object ids')
170
184
_global_option('timezone',
172
186
help='display timezone as local, original, or utc')
187
_global_option('unbound')
173
188
_global_option('verbose',
174
189
help='display more information')
175
190
_global_option('version')
176
191
_global_option('email')
177
192
_global_option('update')
178
_global_option('long')
193
_global_option('log-format', type=str, help="Use this log format")
194
_global_option('long', help='Use detailed log format. Same as --log-format long')
195
_global_option('short', help='Use moderately short log format. Same as --log-format short')
196
_global_option('line', help='Use log format with one line per revision. Same as --log-format line')
179
197
_global_option('root', type=str)
180
198
_global_option('no-backup')
181
199
_global_option('merge-type', type=_parse_merge_type)
182
200
_global_option('pattern', type=str)
183
201
_global_option('quiet')
184
_global_option('remember')
202
_global_option('remember', help='Remember the specified location as a'
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")
187
210
def _global_short(short_name, long_name):