/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_shared_repository.py

  • Committer: Aaron Bentley
  • Date: 2008-10-16 21:37:21 UTC
  • mfrom: (0.12.63 shelf-manager)
  • mto: This revision was merged to the branch mainline in revision 3823.
  • Revision ID: aaron@aaronbentley.com-20081016213721-4evccj16q9mb05uf
Merge with shelf-manager

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
 
2
#
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; either version 2 of the License, or
 
6
# (at your option) any later version.
 
7
#
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
#
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
 
 
17
"""Black-box tests for repositories with shared branches"""
 
18
 
 
19
import os
 
20
 
 
21
from bzrlib.bzrdir import BzrDir
 
22
import bzrlib.errors as errors
 
23
from bzrlib.tests import TestCaseInTempDir
 
24
 
 
25
class TestSharedRepo(TestCaseInTempDir):
 
26
 
 
27
    def test_make_repository(self):
 
28
        out, err = self.run_bzr("init-repository a")
 
29
        self.assertEqual(out,
 
30
"""Shared repository with trees (format: pack-0.92)
 
31
Location:
 
32
  shared repository: a
 
33
""")
 
34
        self.assertEqual(err, "")
 
35
        dir = BzrDir.open('a')
 
36
        self.assertIs(dir.open_repository().is_shared(), True)
 
37
        self.assertRaises(errors.NotBranchError, dir.open_branch)
 
38
        self.assertRaises(errors.NoWorkingTree, dir.open_workingtree)
 
39
 
 
40
    def test_make_repository_quiet(self):
 
41
        out, err = self.run_bzr("init-repository a -q")
 
42
        self.assertEqual(out, "")
 
43
        self.assertEqual(err, "")
 
44
        dir = BzrDir.open('a')
 
45
        self.assertIs(dir.open_repository().is_shared(), True)
 
46
        self.assertRaises(errors.NotBranchError, dir.open_branch)
 
47
        self.assertRaises(errors.NoWorkingTree, dir.open_workingtree)
 
48
 
 
49
    def test_init_repo_existing_dir(self):
 
50
        """Make repo in existing directory.
 
51
        
 
52
        (Malone #38331)
 
53
        """
 
54
        out, err = self.run_bzr("init-repository .")
 
55
        dir = BzrDir.open('.')
 
56
        self.assertTrue(dir.open_repository())
 
57
 
 
58
    def test_init(self):
 
59
        self.run_bzr("init-repo a")
 
60
        self.run_bzr("init --format=default a/b")
 
61
        dir = BzrDir.open('a')
 
62
        self.assertIs(dir.open_repository().is_shared(), True)
 
63
        self.assertRaises(errors.NotBranchError, dir.open_branch)
 
64
        self.assertRaises(errors.NoWorkingTree, dir.open_workingtree)
 
65
        bdir = BzrDir.open('a/b')
 
66
        bdir.open_branch()
 
67
        self.assertRaises(errors.NoRepositoryPresent, bdir.open_repository)
 
68
        wt = bdir.open_workingtree()
 
69
 
 
70
    def test_branch(self):
 
71
        self.run_bzr("init-repo a")
 
72
        self.run_bzr("init --format=default a/b")
 
73
        self.run_bzr('branch a/b a/c')
 
74
        cdir = BzrDir.open('a/c')
 
75
        cdir.open_branch()
 
76
        self.assertRaises(errors.NoRepositoryPresent, cdir.open_repository)
 
77
        cdir.open_workingtree()
 
78
 
 
79
    def test_branch_tree(self):
 
80
        self.run_bzr("init-repo --trees a")
 
81
        self.run_bzr("init --format=default b")
 
82
        file('b/hello', 'wt').write('bar')
 
83
        self.run_bzr("add b/hello")
 
84
        self.run_bzr("commit -m bar b/hello")
 
85
 
 
86
        self.run_bzr('branch b a/c')
 
87
        cdir = BzrDir.open('a/c')
 
88
        cdir.open_branch()
 
89
        self.assertRaises(errors.NoRepositoryPresent, cdir.open_repository)
 
90
        self.failUnlessExists('a/c/hello')
 
91
        cdir.open_workingtree()
 
92
 
 
93
    def test_trees_default(self):
 
94
        # 0.15 switched to trees by default
 
95
        self.run_bzr("init-repo repo")
 
96
        repo = BzrDir.open("repo").open_repository()
 
97
        self.assertEqual(True, repo.make_working_trees())
 
98
 
 
99
    def test_trees_argument(self):
 
100
        # Supplying the --trees argument should be harmless,
 
101
        # as it was previously non-default we need to get it right.
 
102
        self.run_bzr("init-repo --trees trees")
 
103
        repo = BzrDir.open("trees").open_repository()
 
104
        self.assertEqual(True, repo.make_working_trees())
 
105
 
 
106
    def test_no_trees_argument(self):
 
107
        # --no-trees should make it so that there is no working tree
 
108
        self.run_bzr("init-repo --no-trees notrees")
 
109
        repo = BzrDir.open("notrees").open_repository()
 
110
        self.assertEqual(False, repo.make_working_trees())