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