~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_branch.py

  • Committer: John Arbash Meinel
  • Date: 2008-05-21 15:42:47 UTC
  • mto: This revision was merged to the branch mainline in revision 3465.
  • Revision ID: john@arbash-meinel.com-20080521154247-sqpkv9um9grku9e1
Add tests for Branch.missing_revisions and deprecate it.

The api uses a 'stop_revision' but it is supposed to be a revno, not a
revision_id. The code itself is very crufty and slow (and doesn't take
a read_lock). But rather than fix it, just nuke the function.

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
                           UnsupportedFormatError,
51
51
                           )
52
52
 
 
53
from bzrlib.symbol_versioning import deprecated_in
53
54
from bzrlib.tests import TestCase, TestCaseWithTransport
54
55
from bzrlib.transport import get_transport
55
56
 
 
57
 
56
58
class TestDefaultFormat(TestCase):
57
59
 
58
60
    def test_default_format(self):
128
130
    # TODO RBC 20051029 test getting a push location from a branch in a
129
131
    # recursive section - that is, it appends the branch name.
130
132
 
 
133
    def test_missing_revisions(self):
 
134
        t1 = self.make_branch_and_tree('b1', format='knit')
 
135
        rev1 = t1.commit('one')
 
136
        t2 = t1.bzrdir.sprout('b2').open_workingtree()
 
137
        rev2 = t1.commit('two')
 
138
        rev3 = t1.commit('three')
 
139
 
 
140
        self.assertEqual([rev2, rev3],
 
141
            self.applyDeprecated(deprecated_in((1, 6, 0)),
 
142
            t2.branch.missing_revisions, t1.branch))
 
143
 
 
144
        self.assertEqual([],
 
145
            self.applyDeprecated(deprecated_in((1, 6, 0)),
 
146
            t2.branch.missing_revisions, t1.branch, stop_revision=1))
 
147
        self.assertEqual([rev2],
 
148
            self.applyDeprecated(deprecated_in((1, 6, 0)),
 
149
            t2.branch.missing_revisions, t1.branch, stop_revision=2))
 
150
        self.assertEqual([rev2, rev3],
 
151
            self.applyDeprecated(deprecated_in((1, 6, 0)),
 
152
            t2.branch.missing_revisions, t1.branch, stop_revision=3))
 
153
 
 
154
        self.assertRaises(errors.NoSuchRevision,
 
155
            self.applyDeprecated, deprecated_in((1, 6, 0)),
 
156
            t2.branch.missing_revisions, t1.branch, stop_revision=4)
 
157
 
 
158
        rev4 = t2.commit('four')
 
159
        self.assertRaises(errors.DivergedBranches,
 
160
            self.applyDeprecated, deprecated_in((1, 6, 0)),
 
161
            t2.branch.missing_revisions, t1.branch)
 
162
 
 
163
            
 
164
 
131
165
 
132
166
class SampleBranchFormat(BranchFormat):
133
167
    """A sample format
294
328
        self.assertEqual(warnings[0], 'Value "new" is masked by "old" from '
295
329
                         'locations.conf')
296
330
 
 
331
 
297
332
class TestBranchReference(TestCaseWithTransport):
298
333
    """Tests for the branch reference facility."""
299
334