~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/branch_implementations/test_bound_sftp.py

  • Committer: Aaron Bentley
  • Date: 2007-02-06 14:52:16 UTC
  • mfrom: (2266 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2268.
  • Revision ID: abentley@panoramicfeedback.com-20070206145216-fcpi8o3ufvuzwbp9
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import os
21
21
 
22
22
import bzrlib
 
23
from bzrlib import (
 
24
    bzrdir,
 
25
    )
23
26
from bzrlib.branch import Branch
24
27
from bzrlib.bzrdir import (BzrDir,
25
28
                           BzrDirFormat,
34
37
 
35
38
    def create_branches(self):
36
39
        self.build_tree(['base/', 'base/a', 'base/b'])
37
 
        old_format = BzrDirFormat.get_default_format()
38
 
        BzrDirFormat.set_default_format(BzrDirMetaFormat1())
39
 
        try:
40
 
            wt_base = BzrDir.create_standalone_workingtree('base')
41
 
        finally:
42
 
            BzrDirFormat.set_default_format(old_format)
 
40
        format = bzrdir.format_registry.make_bzrdir('knit')
 
41
        wt_base = BzrDir.create_standalone_workingtree('base',
 
42
            format=format)
43
43
    
44
44
        b_base = wt_base.branch
45
45
 
72
72
        # manually make a branch we can bind, because the default format
73
73
        # may not be bindable-from, and we want to test the side effects etc
74
74
        # of bondage.
75
 
        old_format = BzrDirFormat.get_default_format()
76
 
        BzrDirFormat.set_default_format(BzrDirMetaFormat1())
77
 
        try:
78
 
            b_child = BzrDir.create_branch_convenience('child')
79
 
        finally:
80
 
            BzrDirFormat.set_default_format(old_format)
 
75
        format = bzrdir.format_registry.make_bzrdir('knit')
 
76
        b_child = BzrDir.create_branch_convenience('child', format=format)
81
77
        self.assertEqual(None, b_child.get_bound_location())
82
78
        self.assertEqual(None, b_child.get_master_branch())
83
79
 
188
184
        self.assertEqual(['r@b-1'], wt_child.branch.revision_history())
189
185
        self.assertEqual(['r@b-1'], sftp_b_newbase.revision_history())
190
186
 
191
 
    def test_pull_updates_both(self):
192
 
        b_base, wt_child = self.create_branches()
193
 
 
194
 
        wt_newchild = b_base.bzrdir.sprout('newchild').open_workingtree()
195
 
        open('newchild/b', 'wb').write('newchild b contents\n')
196
 
        wt_newchild.commit('newchild', rev_id='r@d-2')
197
 
        self.assertEqual(['r@b-1', 'r@d-2'], wt_newchild.branch.revision_history())
198
 
 
199
 
        wt_child.pull(wt_newchild.branch)
200
 
        self.assertEqual(['r@b-1', 'r@d-2'], wt_child.branch.revision_history())
201
 
        self.assertEqual(['r@b-1', 'r@d-2'], b_base.revision_history())
202
 
 
203
187
    def test_bind_diverged(self):
204
188
        from bzrlib.builtins import merge
205
189
 
337
321
        self.assertRaises(errors.BoundBranchConnectionFailure,
338
322
                wt_child.commit, 'added text', rev_id='r@c-2')
339
323
 
340
 
    def test_pull_fails(self):
341
 
        b_base, wt_child = self.create_branches()
342
 
 
343
 
        wt_other = wt_child.bzrdir.sprout('other').open_workingtree()
344
 
        open('other/a', 'wb').write('new contents\n')
345
 
        wt_other.commit('changed a', rev_id='r@d-2')
346
 
 
347
 
        self.assertEqual(['r@b-1'], b_base.revision_history())
348
 
        self.assertEqual(['r@b-1'], wt_child.branch.revision_history())
349
 
        self.assertEqual(['r@b-1', 'r@d-2'], wt_other.branch.revision_history())
350
 
 
351
 
        # this deletes the branch from memory
352
 
        del b_base
353
 
        # and this moves it out of the way on disk
354
 
        os.rename('base', 'hidden_base')
355
 
 
356
 
        self.assertRaises(errors.BoundBranchConnectionFailure,
357
 
                wt_child.pull, wt_other.branch)
358
 
 
359
324
    # TODO: jam 20051231 We need invasive failure tests, so that we can show
360
325
    #       performance even when something fails.
361
326