/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

Merge bzr.dev, update to use new hooks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
"""Tests of bound branches (binding, unbinding, commit, etc) command."""
19
19
 
20
20
import os
21
 
from cStringIO import StringIO
22
21
 
23
22
from bzrlib import (
24
 
    bzrdir,
25
23
    errors,
26
24
    tests,
27
25
    )
28
26
from bzrlib.branch import Branch
29
 
from bzrlib.bzrdir import (BzrDir, BzrDirFormat, BzrDirMetaFormat1)
30
 
from bzrlib.osutils import getcwd
 
27
from bzrlib.bzrdir import BzrDir
31
28
from bzrlib.tests import script
32
 
import bzrlib.urlutils as urlutils
33
 
from bzrlib.workingtree import WorkingTree
34
 
 
35
 
 
36
 
class TestLegacyFormats(tests.TestCaseWithTransport):
37
 
 
38
 
    def setUp(self):
39
 
        super(TestLegacyFormats, self).setUp()
40
 
        self.build_tree(['master/', 'child/'])
41
 
        self.make_branch_and_tree('master')
42
 
        self.make_branch_and_tree('child',
43
 
                        format=bzrdir.format_registry.make_bzrdir('weave'))
44
 
        os.chdir('child')
45
 
 
46
 
    def test_bind_format_6_bzrdir(self):
47
 
        # bind on a format 6 bzrdir should error
48
 
        out,err = self.run_bzr('bind ../master', retcode=3)
49
 
        self.assertEqual('', out)
50
 
        # TODO: jam 20060427 Probably something like this really should
51
 
        #       print out the actual path, rather than the URL
52
 
        cwd = urlutils.local_path_to_url(getcwd())
53
 
        self.assertEqual('bzr: ERROR: To use this feature you must '
54
 
                         'upgrade your branch at %s/.\n' % cwd, err)
55
 
 
56
 
    def test_unbind_format_6_bzrdir(self):
57
 
        # bind on a format 6 bzrdir should error
58
 
        out,err = self.run_bzr('unbind', retcode=3)
59
 
        self.assertEqual('', out)
60
 
        cwd = urlutils.local_path_to_url(getcwd())
61
 
        self.assertEqual('bzr: ERROR: To use this feature you must '
62
 
                         'upgrade your branch at %s/.\n' % cwd, err)
63
29
 
64
30
 
65
31
class TestBoundBranches(tests.TestCaseWithTransport):
83
49
 
84
50
    def check_revno(self, val, loc='.'):
85
51
        self.assertEqual(
86
 
            val, len(BzrDir.open(loc).open_branch().revision_history()))
 
52
            val, BzrDir.open(loc).open_branch().last_revision_info()[0])
87
53
 
88
54
    def test_simple_binding(self):
89
55
        tree = self.make_branch_and_tree('base')
263
229
        child_tree.commit(message='merged')
264
230
        self.check_revno(3)
265
231
 
266
 
        # After binding, the revision history should be unaltered
267
 
        # take a copy before
268
 
        base_history = base_branch.revision_history()
269
 
        child_history = child_branch.revision_history()
 
232
        self.assertEquals(
 
233
            child_tree.branch.last_revision(),
 
234
            base_tree.branch.last_revision())
270
235
 
271
236
    def test_bind_parent_ahead(self):
272
237
        base_tree = self.create_branches()[0]
367
332
        self.build_tree_contents([('other/c', 'file c\n')])
368
333
        other_tree.add('c')
369
334
        other_tree.commit(message='adding c')
370
 
        new_rev_id = other_branch.revision_history()[-1]
 
335
        new_rev_id = other_branch.last_revision()
371
336
 
372
337
        child_tree.merge_from_branch(other_branch)
373
338
 
374
 
        self.failUnlessExists('child/c')
 
339
        self.assertPathExists('child/c')
375
340
        self.assertEqual([new_rev_id], child_tree.get_parent_ids()[1:])
376
341
 
377
342
        # Make sure the local branch has the installed revision
443
408
    def test_bind_when_bound(self):
444
409
        self.run_script("""
445
410
$ bzr init trunk
 
411
...
446
412
$ bzr init copy
 
413
...
447
414
$ cd copy
448
415
$ bzr bind ../trunk
449
416
$ bzr bind
453
420
    def test_bind_before_bound(self):
454
421
        self.run_script("""
455
422
$ bzr init trunk
 
423
...
456
424
$ cd trunk
457
425
$ bzr bind
458
426
2>bzr: ERROR: No location supplied and no previous location known