~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_revisionspec.py

MergeĀ fromĀ old-hpss-branch-implementation-test.

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
                         ' %r != %r'
74
74
                         % (revision_spec, exp_revision_id, rev_info.rev_id))
75
75
 
76
 
    def assertInvalid(self, revision_spec, extra=''):
 
76
    def assertInvalid(self, revision_spec, extra='',
 
77
                      invalid_as_revision_id=True):
77
78
        try:
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)
82
83
        else:
83
 
            self.fail('Expected InvalidRevisionSpec to be raised for %s'
84
 
                      % (revision_spec,))
 
84
            self.fail('Expected InvalidRevisionSpec to be raised for'
 
85
                      ' %r.in_history' % (revision_spec,))
 
86
        if invalid_as_revision_id:
 
87
            try:
 
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)
 
93
            else:
 
94
                self.fail('Expected InvalidRevisionSpec to be raised for'
 
95
                          ' %r.as_revision_id' % (revision_spec,))
85
96
 
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')
300
311
        
301
312
    def test_missing(self):
302
 
        self.assertInvalid('revid:r3')
 
313
        self.assertInvalid('revid:r3', invalid_as_revision_id=False)
303
314
 
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)
312
323
 
313
324
    def test_in_repository(self):
314
325
        """We can get any revision id in the repository"""