~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_parent.py

Handled simultaneous renames of parent and child better

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