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