69
76
def _parse_revision_str(revstr):
70
77
"""This handles a revision string -> revno.
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()
79
This always returns a list. The list will have one element for
77
82
>>> _parse_revision_str('234')
83
[<RevisionSpec_int 234>]
79
84
>>> _parse_revision_str('234..567')
85
[<RevisionSpec_int 234>, <RevisionSpec_int 567>]
81
86
>>> _parse_revision_str('..')
87
[<RevisionSpec None>, <RevisionSpec None>]
83
88
>>> _parse_revision_str('..234')
89
[<RevisionSpec None>, <RevisionSpec_int 234>]
85
90
>>> _parse_revision_str('234..')
91
[<RevisionSpec_int 234>, <RevisionSpec None>]
87
92
>>> _parse_revision_str('234..456..789') # Maybe this should be an error
93
[<RevisionSpec_int 234>, <RevisionSpec_int 456>, <RevisionSpec_int 789>]
89
94
>>> _parse_revision_str('234....789') # Error?
95
[<RevisionSpec_int 234>, <RevisionSpec None>, <RevisionSpec_int 789>]
91
96
>>> _parse_revision_str('revid:test@other.com-234234')
92
['revid:test@other.com-234234']
97
[<RevisionSpec_revid revid:test@other.com-234234>]
93
98
>>> _parse_revision_str('revid:test@other.com-234234..revid:test@other.com-234235')
94
['revid:test@other.com-234234', 'revid:test@other.com-234235']
99
[<RevisionSpec_revid revid:test@other.com-234234>, <RevisionSpec_revid revid:test@other.com-234235>]
95
100
>>> _parse_revision_str('revid:test@other.com-234234..23')
96
['revid:test@other.com-234234', 23]
101
[<RevisionSpec_revid revid:test@other.com-234234>, <RevisionSpec_int 23>]
97
102
>>> _parse_revision_str('date:2005-04-12')
103
[<RevisionSpec_date date:2005-04-12>]
99
104
>>> _parse_revision_str('date:2005-04-12 12:24:33')
100
['date:2005-04-12 12:24:33']
105
[<RevisionSpec_date date:2005-04-12 12:24:33>]
101
106
>>> _parse_revision_str('date:2005-04-12T12:24:33')
102
['date:2005-04-12T12:24:33']
107
[<RevisionSpec_date date:2005-04-12T12:24:33>]
103
108
>>> _parse_revision_str('date:2005-04-12,12:24:33')
104
['date:2005-04-12,12:24:33']
109
[<RevisionSpec_date date:2005-04-12,12:24:33>]
105
110
>>> _parse_revision_str('-5..23')
111
[<RevisionSpec_int -5>, <RevisionSpec_int 23>]
107
112
>>> _parse_revision_str('-5')
113
[<RevisionSpec_int -5>]
109
114
>>> _parse_revision_str('123a')
115
Traceback (most recent call last):
117
BzrError: No namespace registered for string: '123a'
111
118
>>> _parse_revision_str('abc')
119
Traceback (most recent call last):
121
BzrError: No namespace registered for string: 'abc'
115
124
old_format_re = re.compile('\d*:\d*')
116
125
m = old_format_re.match(revstr)
118
128
warning('Colon separator for revision numbers is deprecated.'
119
129
' Use .. instead')
121
130
for rev in revstr.split(':'):
123
revs.append(int(rev))
128
for x in revstr.split('..'):
132
revs.append(RevisionSpec(int(rev)))
134
revs.append(RevisionSpec(None))
136
for x in revstr.split('..'):
138
revs.append(RevisionSpec(None))
140
revs.append(RevisionSpec(x))
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
144
def _builtin_commands():
154
145
import bzrlib.builtins
403
391
>>> parse_args('commit --message=biter'.split())
404
392
(['commit'], {'message': u'biter'})
405
393
>>> parse_args('log -r 500'.split())
406
(['log'], {'revision': [500]})
394
(['log'], {'revision': [<RevisionSpec_int 500>]})
407
395
>>> parse_args('log -r500..600'.split())
408
(['log'], {'revision': [500, 600]})
396
(['log'], {'revision': [<RevisionSpec_int 500>, <RevisionSpec_int 600>]})
409
397
>>> parse_args('log -vr500..600'.split())
410
(['log'], {'verbose': True, 'revision': [500, 600]})
411
>>> parse_args('log -rv500..600'.split()) #the r takes an argument
412
(['log'], {'revision': ['v500', 600]})
398
(['log'], {'verbose': True, 'revision': [<RevisionSpec_int 500>, <RevisionSpec_int 600>]})
399
>>> parse_args('log -rrevno:500..600'.split()) #the r takes an argument
400
(['log'], {'revision': [<RevisionSpec_revno revno:500>, <RevisionSpec_int 600>]})
635
623
bzrlib.trace.log_startup(argv)
636
624
bzrlib.ui.ui_factory = bzrlib.ui.TextUIFactory()
626
return run_bzr_catch_errors(argv[1:])
629
def run_bzr_catch_errors(argv):
640
return run_bzr(argv[1:])
642
# do this here inside the exception wrappers to catch EPIPE
635
# do this here inside the exception wrappers to catch EPIPE
637
#wrap common errors as CommandErrors.
638
except (NotBranchError,), e:
639
raise BzrCommandError(str(e))
644
640
except BzrCommandError, e:
645
641
# command line syntax error, etc
646
642
log_error(str(e))