/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
1553.5.78 by Martin Pool
New bzr init --format option and test
1
# Copyright (C) 2006 by 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
18
"""Test "bzr init"""
19
1654.1.4 by Robert Collins
Teach `bzr init` how to init at the root of a repository.
20
import os
1553.5.78 by Martin Pool
New bzr init --format option and test
21
1654.1.4 by Robert Collins
Teach `bzr init` how to init at the root of a repository.
22
from bzrlib.bzrdir import BzrDirMetaFormat1
1553.5.78 by Martin Pool
New bzr init --format option and test
23
from bzrlib.tests.blackbox import ExternalBase
1654.1.4 by Robert Collins
Teach `bzr init` how to init at the root of a repository.
24
from bzrlib.workingtree import WorkingTree
1553.5.78 by Martin Pool
New bzr init --format option and test
25
26
27
class TestInit(ExternalBase):
28
29
    def test_init_with_format(self):
30
        """Verify bzr init --format constructs something plausible"""
31
        t = self.get_transport()
32
        self.runbzr('init --format metadir')
33
        self.assertIsDirectory('.bzr', t)
34
        self.assertIsDirectory('.bzr/checkout', t)
35
        self.assertIsDirectory('.bzr/checkout/lock', t)
1654.1.4 by Robert Collins
Teach `bzr init` how to init at the root of a repository.
36
37
    def test_init_at_repository_root(self):
38
        # bzr init at the root of a repository should create a branch
39
        # and working tree even when creation of working trees is disabled.
40
        t = self.get_transport()
41
        t.mkdir('repo')
42
        format = BzrDirMetaFormat1()
43
        newdir = format.initialize(t.abspath('repo'))
44
        repo = newdir.create_repository(shared=True)
45
        repo.set_make_working_trees(False)
46
        out, err = self.run_bzr('init', 'repo')
47
        self.assertEqual('', out)
48
        self.assertEqual('', err)
49
        newdir.open_branch()
50
        newdir.open_workingtree()
51
        
52
    def test_init_branch(self):
53
        out, err = self.run_bzr('init')
54
        self.assertEqual('', out)
55
        self.assertEqual('', err)
56
57
        # Can it handle subdirectories of branches too ?
58
        out, err = self.run_bzr('init', 'subdir1')
59
        self.assertEqual('', out)
60
        self.assertEqual('', err)
61
        WorkingTree.open('subdir1')
62
        
63
        out, err = self.run_bzr('init', 'subdir2/nothere', retcode=3)
64
        self.assertEqual('', out)
65
        self.failUnless(err.startswith(
66
            'bzr: ERROR: exceptions.OSError: '
67
            '[Errno 2] No such file or directory: '))
68
        
69
        os.mkdir('subdir2')
70
        out, err = self.run_bzr('init', 'subdir2')
71
        self.assertEqual('', out)
72
        self.assertEqual('', err)
73
        # init an existing branch.
74
        out, err = self.run_bzr('init', 'subdir2', retcode=3)
75
        self.assertEqual('', out)
76
        self.failUnless(err.startswith('bzr: ERROR: Already a branch:'))