1
# Copyright (C) 2005, 2006 Canonical Ltd
1
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
21
from bzrlib.tests import TestCaseInTempDir
23
21
from bzrlib.bzrdir import BzrDir
24
22
import bzrlib.errors as errors
23
from bzrlib.tests import TestCaseInTempDir
26
25
class TestSharedRepo(TestCaseInTempDir):
29
28
out, err = self.run_bzr("init-repository", "a")
30
29
self.assertEqual(out, "")
31
30
self.assertEqual(err, "")
32
dir = bzrlib.bzrdir.BzrDir.open('a')
31
dir = BzrDir.open('a')
33
32
self.assertIs(dir.open_repository().is_shared(), True)
34
33
self.assertRaises(errors.NotBranchError, dir.open_branch)
35
34
self.assertRaises(errors.NoWorkingTree, dir.open_workingtree)
46
45
def test_init(self):
47
46
self.run_bzr("init-repo", "a")
48
47
self.run_bzr("init", "--format=default", "a/b")
49
dir = bzrlib.bzrdir.BzrDir.open('a')
48
dir = BzrDir.open('a')
50
49
self.assertIs(dir.open_repository().is_shared(), True)
51
50
self.assertRaises(errors.NotBranchError, dir.open_branch)
52
51
self.assertRaises(errors.NoWorkingTree, dir.open_workingtree)
53
bdir = bzrlib.bzrdir.BzrDir.open('a/b')
52
bdir = BzrDir.open('a/b')
55
54
self.assertRaises(errors.NoRepositoryPresent, bdir.open_repository)
56
self.assertRaises(errors.NoWorkingTree, bdir.open_workingtree)
55
wt = bdir.open_workingtree()
58
57
def test_branch(self):
59
58
self.run_bzr("init-repo", "a")
60
59
self.run_bzr("init", "--format=default", "a/b")
61
60
self.run_bzr('branch', 'a/b', 'a/c')
62
cdir = bzrlib.bzrdir.BzrDir.open('a/c')
61
cdir = BzrDir.open('a/c')
64
63
self.assertRaises(errors.NoRepositoryPresent, cdir.open_repository)
65
self.assertRaises(errors.NoWorkingTree, cdir.open_workingtree)
64
cdir.open_workingtree()
67
66
def test_branch_tree(self):
68
67
self.run_bzr("init-repo", "--trees", "a")
72
71
self.run_bzr("commit", "-m", "bar", "b/hello")
74
73
self.run_bzr('branch', 'b', 'a/c')
75
cdir = bzrlib.bzrdir.BzrDir.open('a/c')
74
cdir = BzrDir.open('a/c')
77
76
self.assertRaises(errors.NoRepositoryPresent, cdir.open_repository)
78
77
self.failUnlessExists('a/c/hello')
79
78
cdir.open_workingtree()
80
def test_trees_default(self):
81
# 0.15 switched to trees by default
82
self.run_bzr("init-repo", "repo")
83
repo = BzrDir.open("repo").open_repository()
84
self.assertEqual(True, repo.make_working_trees())
86
def test_trees_argument(self):
87
# Supplying the --trees argument should be harmless,
88
# as it was previously non-default we need to get it right.
89
self.run_bzr("init-repo", "--trees", "trees")
90
repo = BzrDir.open("trees").open_repository()
91
self.assertEqual(True, repo.make_working_trees())
93
def test_no_trees_argument(self):
94
# --no-trees should make it so that there is no working tree
95
self.run_bzr("init-repo", "--no-trees", "notrees")
96
repo = BzrDir.open("notrees").open_repository()
97
self.assertEqual(False, repo.make_working_trees())