~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_parent.py

[merge] jam-integration

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
 
18
18
import os
19
 
from bzrlib.selftest import TestCaseInTempDir
 
19
 
20
20
from bzrlib.branch import Branch
21
 
from bzrlib.clone import copy_branch
 
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):
 
29
 
28
30
    def test_no_default_parent(self):
29
31
        """Branches should have no parent by default"""
30
 
        b = Branch.initialize('.')
 
32
        b = self.make_branch('.')
31
33
        self.assertEquals(b.get_parent(), None)
32
34
        
33
 
    
34
35
    def test_set_get_parent(self):
35
36
        """Set and then re-get the parent"""
36
 
        b = Branch.initialize('.')
 
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.add('foo')
49
 
        branch_from.commit('initial commit')
 
49
        wt.add('foo')
 
50
        wt.commit('initial commit')
50
51
        
51
52
        os.mkdir('to')
52
 
        copy_branch(branch_from, 'to', None)
53
 
 
54
 
        branch_to = Branch.open('to')
55
 
        abspath = os.path.abspath('from')
56
 
        self.assertEquals(branch_to.get_parent(), abspath)
57
 
        
58
 
 
 
53
        branch_to = branch_from.clone('to', None)
 
54
        self.assertEquals(branch_to.get_parent(), branch_from.base)