~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_revisionspec.py

  • Committer: Martin Pool
  • Date: 2011-01-20 23:07:25 UTC
  • mfrom: (5626 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5630.
  • Revision ID: mbp@canonical.com-20110120230725-12l7ltnko5x3fgnz
merge news

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
    )
24
24
from bzrlib.tests import TestCaseWithTransport
25
25
from bzrlib.revisionspec import (
26
 
    RevisionInfo,
27
26
    RevisionSpec,
28
 
    RevisionSpec_dwim,
29
27
    RevisionSpec_tag,
30
28
    )
31
29
 
144
142
        self.assertRaises(TypeError, RevisionSpec.from_string, object())
145
143
 
146
144
 
147
 
class RevisionSpec_bork(RevisionSpec):
148
 
 
149
 
    prefix = 'irrelevant:'
150
 
 
151
 
    def _match_on(self, branch, revs):
152
 
        if self.spec == "bork":
153
 
            return RevisionInfo.from_revision_id(branch, "r1", revs)
154
 
        else:
155
 
            raise errors.InvalidRevisionSpec(self.spec, branch)
156
 
 
157
 
 
158
145
class TestRevisionSpec_dwim(TestRevisionSpec):
159
146
 
160
147
    # Don't need to test revno's explicitly since TRS_revno already
198
185
        self.assertInvalid('1.2..1', invalid_as_revision_id=False)
199
186
        self.assertInvalid('1.', invalid_as_revision_id=False)
200
187
 
201
 
    def test_append_dwim_revspec(self):
202
 
        original_dwim_revspecs = list(RevisionSpec_dwim._possible_revspecs)
203
 
        def reset_dwim_revspecs():
204
 
            RevisionSpec_dwim._possible_revspecs = original_dwim_revspecs
205
 
        self.addCleanup(reset_dwim_revspecs)
206
 
        RevisionSpec_dwim.append_possible_revspec(RevisionSpec_bork)
207
 
        self.assertAsRevisionId('r1', 'bork')
208
 
 
209
 
    def test_append_lazy_dwim_revspec(self):
210
 
        original_dwim_revspecs = list(RevisionSpec_dwim._possible_revspecs)
211
 
        def reset_dwim_revspecs():
212
 
            RevisionSpec_dwim._possible_revspecs = original_dwim_revspecs
213
 
        self.addCleanup(reset_dwim_revspecs)
214
 
        RevisionSpec_dwim.append_possible_lazy_revspec(
215
 
            "bzrlib.tests.test_revisionspec", "RevisionSpec_bork")
216
 
        self.assertAsRevisionId('r1', 'bork')
217
 
 
218
188
 
219
189
class TestRevisionSpec_revno(TestRevisionSpec):
220
190
 
397
367
        """We can get any revision id in the repository"""
398
368
        # XXX: This may change in the future, but for now, it is true
399
369
        self.tree2.commit('alt third', rev_id='alt_r3')
400
 
        self.tree.branch.fetch(self.tree2.branch, 'alt_r3')
 
370
        self.tree.branch.repository.fetch(self.tree2.branch.repository,
 
371
                                          revision_id='alt_r3')
401
372
        self.assertInHistoryIs(None, 'alt_r3', 'revid:alt_r3')
402
373
 
403
374
    def test_unicode(self):
474
445
    def test_alt_no_parents(self):
475
446
        new_tree = self.make_branch_and_tree('new_tree')
476
447
        new_tree.commit('first', rev_id='new_r1')
477
 
        self.tree.branch.fetch(new_tree.branch, 'new_r1')
 
448
        self.tree.branch.repository.fetch(new_tree.branch.repository,
 
449
                                          revision_id='new_r1')
478
450
        self.assertInHistoryIs(0, 'null:', 'before:revid:new_r1')
479
451
 
480
452
    def test_as_revision_id(self):
639
611
        # XXX: Right now, we use fetch() to make sure the remote revisions
640
612
        # have been pulled into the local branch. We may change that
641
613
        # behavior in the future.
642
 
        self.assertTrue(self.tree.branch.repository.has_revision('new_r3'))
 
614
        self.failUnless(self.tree.branch.repository.has_revision('new_r3'))
643
615
 
644
616
    def test_no_commits(self):
645
617
        new_tree = self.make_branch_and_tree('new_tree')