~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2012-01-05 17:56:30 UTC
  • mfrom: (6434 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6468.
  • Revision ID: v.ladeuil+lp@free.fr-20120105175630-kp0kt0el27s40q0x
Merge trunk resolving conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
"""Tests of bound branches (binding, unbinding, commit, etc) command."""
19
19
 
20
 
import os
21
 
 
22
20
from bzrlib import (
 
21
    branch,
 
22
    bzrdir,
23
23
    errors,
24
24
    tests,
25
25
    )
26
 
from bzrlib.branch import Branch
27
 
from bzrlib.bzrdir import BzrDir
28
26
from bzrlib.tests import script
29
27
 
30
28
 
42
40
        child_tree = branch.create_checkout('child')
43
41
 
44
42
        self.check_revno(1, 'child')
45
 
        d = BzrDir.open('child')
 
43
        d = bzrdir.BzrDir.open('child')
46
44
        self.assertNotEqual(None, d.open_branch().get_master_branch())
47
45
 
48
46
        return base_tree, child_tree
49
47
 
50
48
    def check_revno(self, val, loc='.'):
51
49
        self.assertEqual(
52
 
            val, BzrDir.open(loc).open_branch().last_revision_info()[0])
 
50
            val, bzrdir.BzrDir.open(loc).open_branch().last_revision_info()[0])
53
51
 
54
52
    def test_simple_binding(self):
55
53
        tree = self.make_branch_and_tree('base')
56
54
        self.build_tree(['base/a', 'base/b'])
57
55
        tree.add('a', 'b')
58
56
        tree.commit(message='init')
59
 
        branch = tree.branch
60
57
 
61
58
        tree.bzrdir.sprout('child')
62
59
 
63
60
        self.run_bzr('bind ../base', working_dir='child')
64
61
 
65
 
        d = BzrDir.open('child')
 
62
        d = bzrdir.BzrDir.open('child')
66
63
        self.assertNotEqual(None, d.open_branch().get_master_branch())
67
64
 
68
65
        self.run_bzr('unbind', working_dir='child')
73
70
    def test_bind_branch6(self):
74
71
        branch1 = self.make_branch('branch1', format='dirstate-tags')
75
72
        error = self.run_bzr('bind', retcode=3, working_dir='branch1')[1]
76
 
        self.assertContainsRe(error, 'no previous location known')
 
73
        self.assertEndsWith(
 
74
            error, 'No location supplied and no previous location known\n')
77
75
 
78
76
    def setup_rebind(self, format):
79
77
        branch1 = self.make_branch('branch1')
84
82
    def test_rebind_branch6(self):
85
83
        self.setup_rebind('dirstate-tags')
86
84
        self.run_bzr('bind', working_dir='branch2')
87
 
        b = Branch.open('branch2')
88
 
        self.assertContainsRe(b.get_bound_location(), '\/branch1\/$')
 
85
        b = branch.Branch.open('branch2')
 
86
        self.assertEndsWith(b.get_bound_location(), '/branch1/')
89
87
 
90
88
    def test_rebind_branch5(self):
91
89
        self.setup_rebind('knit')
92
90
        error = self.run_bzr('bind', retcode=3, working_dir='branch2')[1]
93
 
        self.assertContainsRe(error, 'old locations')
 
91
        self.assertEndsWith(
 
92
            error, 'No location supplied.  This format does not remember'
 
93
            ' old locations.\n')
94
94
 
95
95
    def test_bound_commit(self):
96
96
        child_tree = self.create_branches()[1]
181
181
        # the bound parent branch
182
182
        self.run_bzr('pull ../newchild', working_dir='child')
183
183
        self.check_revno(2, 'child')
184
 
 
185
184
        self.check_revno(2, 'base')
186
185
 
187
186
    def test_pull_local_updates_local(self):
195
194
        # the bound parent branch
196
195
        self.run_bzr('pull ../newchild --local', working_dir='child')
197
196
        self.check_revno(2, 'child')
198
 
 
199
197
        self.check_revno(1, 'base')
200
198
 
201
199
    def test_bind_diverged(self):
221
219
        child_tree.update()
222
220
        child_tree.commit(message='merged')
223
221
        self.check_revno(3, 'child')
224
 
 
225
 
        self.assertEquals(
226
 
            child_tree.branch.last_revision(),
227
 
            base_tree.branch.last_revision())
 
222
        self.assertEquals(child_tree.branch.last_revision(),
 
223
                          base_tree.branch.last_revision())
228
224
 
229
225
    def test_bind_parent_ahead(self):
230
226
        base_tree = self.create_branches()[0]
286
282
                           working_dir='tree_1')
287
283
        self.assertIs(None, tree.branch.get_bound_location())
288
284
 
289
 
    def test_bind_nick(self):
290
 
        """Bind should not update implicit nick."""
291
 
        base = self.make_branch_and_tree('base')
292
 
        child = self.make_branch_and_tree('child')
293
 
        self.assertEqual(child.branch.nick, 'child')
294
 
        self.assertEqual(False,
295
 
                         child.branch.get_config().has_explicit_nickname())
296
 
        self.run_bzr('bind ../base', working_dir='child')
297
 
        # Refresh the child tree/branch objects as 'bind' modified them
298
 
        child = BzrDir.open('child').open_workingtree()
299
 
        self.assertEqual(child.branch.nick, base.branch.nick)
300
 
        self.assertEqual(False,
301
 
                         child.branch.get_config().has_explicit_nickname())
302
 
 
303
 
    def test_bind_explicit_nick(self):
304
 
        """Bind should update explicit nick."""
305
 
        base = self.make_branch_and_tree('base')
306
 
        child = self.make_branch_and_tree('child')
307
 
        child.branch.nick = "explicit_nick"
308
 
        self.assertEqual("explicit_nick", child.branch.nick)
309
 
        self.assertEqual("explicit_nick",
310
 
                         child.branch.get_config()._get_explicit_nickname())
311
 
        self.run_bzr('bind ../base', working_dir='child')
312
 
        # Refresh the child tree/branch objects as 'bind' modified them
313
 
        child = BzrDir.open('child').open_workingtree()
314
 
        self.assertEqual(child.branch.nick, base.branch.nick)
315
 
        self.assertEqual(child.branch.get_config()._get_explicit_nickname(),
316
 
                         base.branch.nick)
317
 
 
318
285
    def test_commit_after_merge(self):
319
286
        base_tree, child_tree = self.create_branches()
320
287
 
344
311
        # Commit should succeed, and cause merged revisions to
345
312
        # be pulled into base
346
313
        self.run_bzr(['commit', '-m', 'merge other'], working_dir='child')
347
 
 
348
314
        self.check_revno(2, 'child')
349
 
 
350
315
        self.check_revno(2, 'base')
351
 
 
352
316
        self.assertTrue(base_tree.branch.repository.has_revision(new_rev_id))
353
317
 
354
318
    def test_pull_overwrite(self):
390
354
        branch = tree.branch
391
355
        tree.bzrdir.sprout('child')
392
356
        self.run_bzr('bind --directory=child base')
393
 
        d = BzrDir.open('child')
 
357
        d = bzrdir.BzrDir.open('child')
394
358
        self.assertNotEqual(None, d.open_branch().get_master_branch())
395
359
        self.run_bzr('unbind -d child')
396
360
        self.assertEqual(None, d.open_branch().get_master_branch())