~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_parent.py

[merge] update from bzr.dev

Show diffs side-by-side

added added

removed removed

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