70
76
def _parse_revision_str(revstr):
71
77
"""This handles a revision string -> revno.
73
This always returns a list. The list will have one element for
79
This always returns a list. The list will have one element for
81
It supports integers directly, but everything else it
82
defers for passing to Branch.get_revision_info()
76
84
>>> _parse_revision_str('234')
77
[<RevisionSpec_int 234>]
78
86
>>> _parse_revision_str('234..567')
79
[<RevisionSpec_int 234>, <RevisionSpec_int 567>]
80
88
>>> _parse_revision_str('..')
81
[<RevisionSpec None>, <RevisionSpec None>]
82
90
>>> _parse_revision_str('..234')
83
[<RevisionSpec None>, <RevisionSpec_int 234>]
84
92
>>> _parse_revision_str('234..')
85
[<RevisionSpec_int 234>, <RevisionSpec None>]
86
94
>>> _parse_revision_str('234..456..789') # Maybe this should be an error
87
[<RevisionSpec_int 234>, <RevisionSpec_int 456>, <RevisionSpec_int 789>]
88
96
>>> _parse_revision_str('234....789') # Error?
89
[<RevisionSpec_int 234>, <RevisionSpec None>, <RevisionSpec_int 789>]
90
98
>>> _parse_revision_str('revid:test@other.com-234234')
91
[<RevisionSpec_revid revid:test@other.com-234234>]
99
['revid:test@other.com-234234']
92
100
>>> _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>]
101
['revid:test@other.com-234234', 'revid:test@other.com-234235']
94
102
>>> _parse_revision_str('revid:test@other.com-234234..23')
95
[<RevisionSpec_revid revid:test@other.com-234234>, <RevisionSpec_int 23>]
103
['revid:test@other.com-234234', 23]
96
104
>>> _parse_revision_str('date:2005-04-12')
97
[<RevisionSpec_date date:2005-04-12>]
98
106
>>> _parse_revision_str('date:2005-04-12 12:24:33')
99
[<RevisionSpec_date date:2005-04-12 12:24:33>]
107
['date:2005-04-12 12:24:33']
100
108
>>> _parse_revision_str('date:2005-04-12T12:24:33')
101
[<RevisionSpec_date date:2005-04-12T12:24:33>]
109
['date:2005-04-12T12:24:33']
102
110
>>> _parse_revision_str('date:2005-04-12,12:24:33')
103
[<RevisionSpec_date date:2005-04-12,12:24:33>]
111
['date:2005-04-12,12:24:33']
104
112
>>> _parse_revision_str('-5..23')
105
[<RevisionSpec_int -5>, <RevisionSpec_int 23>]
106
114
>>> _parse_revision_str('-5')
107
[<RevisionSpec_int -5>]
108
116
>>> _parse_revision_str('123a')
109
Traceback (most recent call last):
111
BzrError: No namespace registered for string: '123a'
112
118
>>> _parse_revision_str('abc')
113
Traceback (most recent call last):
115
BzrError: No namespace registered for string: 'abc'
118
122
old_format_re = re.compile('\d*:\d*')
119
123
m = old_format_re.match(revstr)
122
125
warning('Colon separator for revision numbers is deprecated.'
123
126
' Use .. instead')
124
128
for rev in revstr.split(':'):
126
revs.append(RevisionSpec(int(rev)))
128
revs.append(RevisionSpec(None))
130
for x in revstr.split('..'):
132
revs.append(RevisionSpec(None))
134
revs.append(RevisionSpec(x))
130
revs.append(int(rev))
135
for x in revstr.split('..'):
146
def get_merge_type(typestring):
147
"""Attempt to find the merge class/factory associated with a string."""
148
from merge import merge_types
150
return merge_types[typestring][0]
152
templ = '%s%%7s: %%s' % (' '*12)
153
lines = [templ % (f[0], f[1][1]) for f in merge_types.iteritems()]
154
type_list = '\n'.join(lines)
155
msg = "No known merge type %s. Supported types are:\n%s" %\
156
(typestring, type_list)
157
raise BzrCommandError(msg)
138
160
def _builtin_commands():
139
161
import bzrlib.builtins
386
408
>>> parse_args('commit --message=biter'.split())
387
409
(['commit'], {'message': u'biter'})
388
410
>>> parse_args('log -r 500'.split())
389
(['log'], {'revision': [<RevisionSpec_int 500>]})
411
(['log'], {'revision': [500]})
390
412
>>> parse_args('log -r500..600'.split())
391
(['log'], {'revision': [<RevisionSpec_int 500>, <RevisionSpec_int 600>]})
413
(['log'], {'revision': [500, 600]})
392
414
>>> parse_args('log -vr500..600'.split())
393
(['log'], {'verbose': True, 'revision': [<RevisionSpec_int 500>, <RevisionSpec_int 600>]})
394
>>> parse_args('log -rrevno:500..600'.split()) #the r takes an argument
395
(['log'], {'revision': [<RevisionSpec_revno revno:500>, <RevisionSpec_int 600>]})
415
(['log'], {'verbose': True, 'revision': [500, 600]})
416
>>> parse_args('log -rv500..600'.split()) #the r takes an argument
417
(['log'], {'revision': ['v500', 600]})
618
640
bzrlib.trace.log_startup(argv)
619
641
bzrlib.ui.ui_factory = bzrlib.ui.TextUIFactory()
621
return run_bzr_catch_errors(argv[1:])
624
def run_bzr_catch_errors(argv):
629
# do this here inside the exception wrappers to catch EPIPE
646
return run_bzr(argv[1:])
648
# do this here inside the exception wrappers to catch EPIPE
650
#wrap common errors as CommandErrors.
651
except (NotBranchError,), e:
652
raise BzrCommandError(str(e))
631
653
except BzrCommandError, e:
632
654
# command line syntax error, etc
633
655
log_error(str(e))