74
74
% (revision_spec, exp_revision_id, rev_info.rev_id))
76
def assertInvalid(self, revision_spec, extra=''):
76
def assertInvalid(self, revision_spec, extra='',
77
invalid_as_revision_id=True):
78
79
self.get_in_history(revision_spec)
79
80
except errors.InvalidRevisionSpec, e:
80
81
self.assertEqual(revision_spec, e.spec)
81
82
self.assertEqual(extra, e.extra)
83
self.fail('Expected InvalidRevisionSpec to be raised for %s'
84
self.fail('Expected InvalidRevisionSpec to be raised for'
85
' %r.in_history' % (revision_spec,))
86
if invalid_as_revision_id:
88
spec = RevisionSpec.from_string(revision_spec)
89
spec.as_revision_id(self.tree.branch)
90
except errors.InvalidRevisionSpec, e:
91
self.assertEqual(revision_spec, e.spec)
92
self.assertEqual(extra, e.extra)
94
self.fail('Expected InvalidRevisionSpec to be raised for'
95
' %r.as_revision_id' % (revision_spec,))
86
97
def assertAsRevisionId(self, revision_id, revision_spec):
87
98
"""Calling as_revision_id() should return the specified id."""
299
310
self.assertInHistoryIs(2, 'r2', 'revid:r2')
301
312
def test_missing(self):
302
self.assertInvalid('revid:r3')
313
self.assertInvalid('revid:r3', invalid_as_revision_id=False)
304
315
def test_merged(self):
305
316
"""We can reach revisions in the ancestry"""
308
319
def test_not_here(self):
309
320
self.tree2.commit('alt third', rev_id='alt_r3')
310
321
# It exists in tree2, but not in tree
311
self.assertInvalid('revid:alt_r3')
322
self.assertInvalid('revid:alt_r3', invalid_as_revision_id=False)
313
324
def test_in_repository(self):
314
325
"""We can get any revision id in the repository"""