~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_parent.py

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
 
18
18
import os
 
19
 
19
20
from bzrlib.branch import Branch
20
 
from bzrlib.tests import TestCaseInTempDir
21
21
from bzrlib.osutils import abspath, realpath
 
22
from bzrlib.tests import TestCaseWithTransport
22
23
 
23
24
 
24
25
"""Tests for Branch parent URL"""
25
26
 
26
27
 
27
 
class TestParent(TestCaseInTempDir):
 
28
class TestParent(TestCaseWithTransport):
28
29
 
29
30
    def test_no_default_parent(self):
30
31
        """Branches should have no parent by default"""
31
 
        b = Branch.initialize(u'.')
 
32
        b = self.make_branch('.')
32
33
        self.assertEquals(b.get_parent(), None)
33
34
        
34
35
    def test_set_get_parent(self):
35
36
        """Set and then re-get the parent"""
36
 
        b = Branch.initialize(u'.')
 
37
        b = self.make_branch('.')
37
38
        url = 'http://bazaar-ng.org/bzr/bzr.dev'
38
39
        b.set_parent(url)
39
40
        self.assertEquals(b.get_parent(), url)
42
43
        """The branch command should set the new branch's parent"""
43
44
        from bzrlib.commands import run_bzr
44
45
 
45
 
        os.mkdir('from')
46
 
        branch_from = Branch.initialize('from')
 
46
        wt = self.make_branch_and_tree('from')
 
47
        branch_from = wt.branch
47
48
        file('from/foo', 'wt').write('contents of foo')
48
 
        branch_from.working_tree().add('foo')
49
 
        branch_from.working_tree().commit('initial commit')
 
49
        wt.add('foo')
 
50
        wt.commit('initial commit')
50
51
        
51
52
        os.mkdir('to')
52
 
        branch_from.clone('to', None)
53
 
 
54
 
        branch_to = Branch.open('to')
 
53
        branch_to = branch_from.clone('to', None)
55
54
        self.assertEquals(branch_to.get_parent(), branch_from.base)