70
69
def _parse_revision_str(revstr):
71
70
"""This handles a revision string -> revno.
73
This always returns a list. The list will have one element for
74
each revision specifier supplied.
72
This always returns a list. The list will have one element for
74
It supports integers directly, but everything else it
75
defers for passing to Branch.get_revision_info()
76
77
>>> _parse_revision_str('234')
77
[<RevisionSpec_int 234>]
78
79
>>> _parse_revision_str('234..567')
79
[<RevisionSpec_int 234>, <RevisionSpec_int 567>]
80
81
>>> _parse_revision_str('..')
81
[<RevisionSpec None>, <RevisionSpec None>]
82
83
>>> _parse_revision_str('..234')
83
[<RevisionSpec None>, <RevisionSpec_int 234>]
84
85
>>> _parse_revision_str('234..')
85
[<RevisionSpec_int 234>, <RevisionSpec None>]
86
87
>>> _parse_revision_str('234..456..789') # Maybe this should be an error
87
[<RevisionSpec_int 234>, <RevisionSpec_int 456>, <RevisionSpec_int 789>]
88
>>> _parse_revision_str('234....789') #Error ?
89
[<RevisionSpec_int 234>, <RevisionSpec None>, <RevisionSpec_int 789>]
89
>>> _parse_revision_str('234....789') # Error?
90
91
>>> _parse_revision_str('revid:test@other.com-234234')
91
[<RevisionSpec_revid revid:test@other.com-234234>]
92
['revid:test@other.com-234234']
92
93
>>> _parse_revision_str('revid:test@other.com-234234..revid:test@other.com-234235')
93
[<RevisionSpec_revid revid:test@other.com-234234>, <RevisionSpec_revid revid:test@other.com-234235>]
94
['revid:test@other.com-234234', 'revid:test@other.com-234235']
94
95
>>> _parse_revision_str('revid:test@other.com-234234..23')
95
[<RevisionSpec_revid revid:test@other.com-234234>, <RevisionSpec_int 23>]
96
['revid:test@other.com-234234', 23]
96
97
>>> _parse_revision_str('date:2005-04-12')
97
[<RevisionSpec_date date:2005-04-12>]
98
99
>>> _parse_revision_str('date:2005-04-12 12:24:33')
99
[<RevisionSpec_date date:2005-04-12 12:24:33>]
100
['date:2005-04-12 12:24:33']
100
101
>>> _parse_revision_str('date:2005-04-12T12:24:33')
101
[<RevisionSpec_date date:2005-04-12T12:24:33>]
102
['date:2005-04-12T12:24:33']
102
103
>>> _parse_revision_str('date:2005-04-12,12:24:33')
103
[<RevisionSpec_date date:2005-04-12,12:24:33>]
104
['date:2005-04-12,12:24:33']
104
105
>>> _parse_revision_str('-5..23')
105
[<RevisionSpec_int -5>, <RevisionSpec_int 23>]
106
107
>>> _parse_revision_str('-5')
107
[<RevisionSpec_int -5>]
108
109
>>> _parse_revision_str('123a')
109
Traceback (most recent call last):
111
BzrError: No namespace registered for string: '123a'
112
111
>>> _parse_revision_str('abc')
113
Traceback (most recent call last):
115
BzrError: No namespace registered for string: 'abc'
116
>>> _parse_revision_str('branch:../branch2')
117
[<RevisionSpec_branch branch:../branch2>]
120
115
old_format_re = re.compile('\d*:\d*')
121
116
m = old_format_re.match(revstr)
124
118
warning('Colon separator for revision numbers is deprecated.'
125
119
' Use .. instead')
126
121
for rev in revstr.split(':'):
128
revs.append(RevisionSpec(int(rev)))
130
revs.append(RevisionSpec(None))
133
for x in revstr.split('..'):
135
revs.append(RevisionSpec(None))
137
# looks like a namespace:.. has happened
138
next_prefix = x + '..'
140
if next_prefix is not None:
142
revs.append(RevisionSpec(x))
144
if next_prefix is not None:
145
revs.append(RevisionSpec(next_prefix))
123
revs.append(int(rev))
128
for x in revstr.split('..'):
139
def get_merge_type(typestring):
140
"""Attempt to find the merge class/factory associated with a string."""
141
from merge import merge_types
143
return merge_types[typestring][0]
145
templ = '%s%%7s: %%s' % (' '*12)
146
lines = [templ % (f[0], f[1][1]) for f in merge_types.iteritems()]
147
type_list = '\n'.join(lines)
148
msg = "No known merge type %s. Supported types are:\n%s" %\
149
(typestring, type_list)
150
raise BzrCommandError(msg)
153
def get_merge_type(typestring):
154
"""Attempt to find the merge class/factory associated with a string."""
155
from merge import merge_types
157
return merge_types[typestring][0]
159
templ = '%s%%7s: %%s' % (' '*12)
160
lines = [templ % (f[0], f[1][1]) for f in merge_types.iteritems()]
161
type_list = '\n'.join(lines)
162
msg = "No known merge type %s. Supported types are:\n%s" %\
163
(typestring, type_list)
164
raise BzrCommandError(msg)
149
167
def _builtin_commands():
150
168
import bzrlib.builtins
400
417
>>> parse_args('commit --message=biter'.split())
401
418
(['commit'], {'message': u'biter'})
402
419
>>> parse_args('log -r 500'.split())
403
(['log'], {'revision': [<RevisionSpec_int 500>]})
420
(['log'], {'revision': [500]})
404
421
>>> parse_args('log -r500..600'.split())
405
(['log'], {'revision': [<RevisionSpec_int 500>, <RevisionSpec_int 600>]})
422
(['log'], {'revision': [500, 600]})
406
423
>>> parse_args('log -vr500..600'.split())
407
(['log'], {'verbose': True, 'revision': [<RevisionSpec_int 500>, <RevisionSpec_int 600>]})
408
>>> parse_args('log -rrevno:500..600'.split()) #the r takes an argument
409
(['log'], {'revision': [<RevisionSpec_revno revno:500>, <RevisionSpec_int 600>]})
424
(['log'], {'verbose': True, 'revision': [500, 600]})
425
>>> parse_args('log -rv500..600'.split()) #the r takes an argument
426
(['log'], {'revision': ['v500', 600]})