~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_bound_branches.py

  • Committer: Jelmer Vernooij
  • Date: 2012-04-16 11:08:11 UTC
  • mfrom: (6521 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6522.
  • Revision ID: jelmer@samba.org-20120416110811-0y996ihqy9o2bb1t
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
from bzrlib import (
21
21
    branch,
22
 
    bzrdir,
 
22
    controldir,
23
23
    errors,
24
24
    tests,
25
25
    )
35
35
        base_tree.add(['a', 'b'])
36
36
        base_tree.commit('init')
37
37
        base_tree.unlock()
38
 
        branch = base_tree.branch
39
38
 
40
 
        child_tree = branch.create_checkout('child')
 
39
        child_tree = base_tree.branch.create_checkout('child')
41
40
 
42
41
        self.check_revno(1, 'child')
43
 
        d = bzrdir.BzrDir.open('child')
 
42
        d = controldir.ControlDir.open('child')
44
43
        self.assertNotEqual(None, d.open_branch().get_master_branch())
45
44
 
46
45
        return base_tree, child_tree
47
46
 
48
47
    def check_revno(self, val, loc='.'):
49
48
        self.assertEqual(
50
 
            val, bzrdir.BzrDir.open(loc).open_branch().last_revision_info()[0])
 
49
            val, controldir.ControlDir.open(loc).open_branch().last_revision_info()[0])
51
50
 
52
51
    def test_simple_binding(self):
53
52
        tree = self.make_branch_and_tree('base')
59
58
 
60
59
        self.run_bzr('bind ../base', working_dir='child')
61
60
 
62
 
        d = bzrdir.BzrDir.open('child')
 
61
        d = controldir.ControlDir.open('child')
63
62
        self.assertNotEqual(None, d.open_branch().get_master_branch())
64
63
 
65
64
        self.run_bzr('unbind', working_dir='child')
127
126
 
128
127
    def test_double_binding(self):
129
128
        child_tree = self.create_branches()[1]
130
 
 
131
 
        child2_tree = child_tree.bzrdir.sprout('child2').open_workingtree()
 
129
        child_tree.bzrdir.sprout('child2')
132
130
 
133
131
        # Double binding succeeds, but committing to child2 should fail
134
132
        self.run_bzr('bind ../child', working_dir='child2')
135
133
 
 
134
        # Refresh the child tree object as 'unbind' modified it
 
135
        child2_tree = controldir.ControlDir.open('child2').open_workingtree()
136
136
        self.assertRaises(errors.CommitToDoubleBoundBranch,
137
137
                child2_tree.commit, message='child2', allow_pointless=True)
138
138
 
150
150
        self.run_bzr("commit -m child", retcode=3, working_dir='child')
151
151
        self.check_revno(1, 'child')
152
152
        self.run_bzr('unbind', working_dir='child')
 
153
        # Refresh the child tree/branch objects as 'unbind' modified them
 
154
        child_tree = child_tree.bzrdir.open_workingtree()
153
155
        child_tree.commit(message='child')
154
156
        self.check_revno(2, 'child')
155
157
 
200
202
 
201
203
        self.run_bzr('unbind', working_dir='child')
202
204
 
 
205
        # Refresh the child tree/branch objects as 'unbind' modified them
 
206
        child_tree = child_tree.bzrdir.open_workingtree()
203
207
        child_tree.commit(message='child', allow_pointless=True)
204
208
        self.check_revno(2, 'child')
205
209
 
210
214
        # These branches have diverged, but bind should succeed anyway
211
215
        self.run_bzr('bind ../base', working_dir='child')
212
216
 
 
217
        # Refresh the child tree/branch objects as 'bind' modified them
 
218
        child_tree = child_tree.bzrdir.open_workingtree()
213
219
        # This should turn the local commit into a merge
214
220
        child_tree.update()
215
221
        child_tree.commit(message='merged')
248
254
        child_tree = self.create_branches()[1]
249
255
 
250
256
        self.run_bzr('unbind', working_dir='child')
 
257
        # Refresh the child tree/branch objects as 'bind' modified them
 
258
        child_tree = child_tree.bzrdir.open_workingtree()
251
259
        child_tree.commit(message='child', allow_pointless=True)
252
260
        self.check_revno(2, 'child')
253
261
        self.check_revno(1, 'base')
347
355
        branch = tree.branch
348
356
        tree.bzrdir.sprout('child')
349
357
        self.run_bzr('bind --directory=child base')
350
 
        d = bzrdir.BzrDir.open('child')
 
358
        d = controldir.ControlDir.open('child')
351
359
        self.assertNotEqual(None, d.open_branch().get_master_branch())
352
360
        self.run_bzr('unbind -d child')
353
361
        self.assertEqual(None, d.open_branch().get_master_branch())