76
76
def _parse_revision_str(revstr):
77
77
"""This handles a revision string -> revno.
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()
79
This always returns a list. The list will have one element for
84
82
>>> _parse_revision_str('234')
83
[<RevisionSpec_int 234>]
86
84
>>> _parse_revision_str('234..567')
85
[<RevisionSpec_int 234>, <RevisionSpec_int 567>]
88
86
>>> _parse_revision_str('..')
87
[<RevisionSpec None>, <RevisionSpec None>]
90
88
>>> _parse_revision_str('..234')
89
[<RevisionSpec None>, <RevisionSpec_int 234>]
92
90
>>> _parse_revision_str('234..')
91
[<RevisionSpec_int 234>, <RevisionSpec None>]
94
92
>>> _parse_revision_str('234..456..789') # Maybe this should be an error
93
[<RevisionSpec_int 234>, <RevisionSpec_int 456>, <RevisionSpec_int 789>]
96
94
>>> _parse_revision_str('234....789') # Error?
95
[<RevisionSpec_int 234>, <RevisionSpec None>, <RevisionSpec_int 789>]
98
96
>>> _parse_revision_str('revid:test@other.com-234234')
99
['revid:test@other.com-234234']
97
[<RevisionSpec_revid revid:test@other.com-234234>]
100
98
>>> _parse_revision_str('revid:test@other.com-234234..revid:test@other.com-234235')
101
['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>]
102
100
>>> _parse_revision_str('revid:test@other.com-234234..23')
103
['revid:test@other.com-234234', 23]
101
[<RevisionSpec_revid revid:test@other.com-234234>, <RevisionSpec_int 23>]
104
102
>>> _parse_revision_str('date:2005-04-12')
103
[<RevisionSpec_date date:2005-04-12>]
106
104
>>> _parse_revision_str('date:2005-04-12 12:24:33')
107
['date:2005-04-12 12:24:33']
105
[<RevisionSpec_date date:2005-04-12 12:24:33>]
108
106
>>> _parse_revision_str('date:2005-04-12T12:24:33')
109
['date:2005-04-12T12:24:33']
107
[<RevisionSpec_date date:2005-04-12T12:24:33>]
110
108
>>> _parse_revision_str('date:2005-04-12,12:24:33')
111
['date:2005-04-12,12:24:33']
109
[<RevisionSpec_date date:2005-04-12,12:24:33>]
112
110
>>> _parse_revision_str('-5..23')
111
[<RevisionSpec_int -5>, <RevisionSpec_int 23>]
114
112
>>> _parse_revision_str('-5')
113
[<RevisionSpec_int -5>]
116
114
>>> _parse_revision_str('123a')
115
Traceback (most recent call last):
117
BzrError: No namespace registered for string: '123a'
118
118
>>> _parse_revision_str('abc')
119
Traceback (most recent call last):
121
BzrError: No namespace registered for string: 'abc'
122
124
old_format_re = re.compile('\d*:\d*')
123
125
m = old_format_re.match(revstr)
125
128
warning('Colon separator for revision numbers is deprecated.'
126
129
' Use .. instead')
128
130
for rev in revstr.split(':'):
130
revs.append(int(rev))
135
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))
408
406
>>> parse_args('commit --message=biter'.split())
409
407
(['commit'], {'message': u'biter'})
410
408
>>> parse_args('log -r 500'.split())
411
(['log'], {'revision': [500]})
409
(['log'], {'revision': [<RevisionSpec_int 500>]})
412
410
>>> parse_args('log -r500..600'.split())
413
(['log'], {'revision': [500, 600]})
411
(['log'], {'revision': [<RevisionSpec_int 500>, <RevisionSpec_int 600>]})
414
412
>>> parse_args('log -vr500..600'.split())
415
(['log'], {'verbose': True, 'revision': [500, 600]})
416
>>> parse_args('log -rv500..600'.split()) #the r takes an argument
417
(['log'], {'revision': ['v500', 600]})
413
(['log'], {'verbose': True, 'revision': [<RevisionSpec_int 500>, <RevisionSpec_int 600>]})
414
>>> parse_args('log -rrevno:500..600'.split()) #the r takes an argument
415
(['log'], {'revision': [<RevisionSpec_revno revno:500>, <RevisionSpec_int 600>]})