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): |
|
|
1666.1.3
by Robert Collins
Fix and test upgrades from bzrdir 6 over SFTP. |
30 |
# Verify bzr init --format constructs something plausible
|
|
1553.5.78
by Martin Pool
New bzr init --format option and test |
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 |
|
|
1666.1.3
by Robert Collins
Fix and test upgrades from bzrdir 6 over SFTP. |
37 |
def test_init_weave(self): |
38 |
# --format=weave should be accepted to allow interoperation with
|
|
39 |
# old releases when desired.
|
|
40 |
out, err = self.run_bzr('init', '--format=weave') |
|
41 |
self.assertEqual('', out) |
|
42 |
self.assertEqual('', err) |
|
43 |
||
|
1654.1.4
by Robert Collins
Teach `bzr init` how to init at the root of a repository. |
44 |
def test_init_at_repository_root(self): |
45 |
# bzr init at the root of a repository should create a branch
|
|
46 |
# and working tree even when creation of working trees is disabled.
|
|
47 |
t = self.get_transport() |
|
48 |
t.mkdir('repo') |
|
49 |
format = BzrDirMetaFormat1() |
|
50 |
newdir = format.initialize(t.abspath('repo')) |
|
51 |
repo = newdir.create_repository(shared=True) |
|
52 |
repo.set_make_working_trees(False) |
|
53 |
out, err = self.run_bzr('init', 'repo') |
|
54 |
self.assertEqual('', out) |
|
55 |
self.assertEqual('', err) |
|
56 |
newdir.open_branch() |
|
57 |
newdir.open_workingtree() |
|
58 |
||
59 |
def test_init_branch(self): |
|
60 |
out, err = self.run_bzr('init') |
|
61 |
self.assertEqual('', out) |
|
62 |
self.assertEqual('', err) |
|
63 |
||
64 |
# Can it handle subdirectories of branches too ?
|
|
65 |
out, err = self.run_bzr('init', 'subdir1') |
|
66 |
self.assertEqual('', out) |
|
67 |
self.assertEqual('', err) |
|
68 |
WorkingTree.open('subdir1') |
|
69 |
||
70 |
out, err = self.run_bzr('init', 'subdir2/nothere', retcode=3) |
|
71 |
self.assertEqual('', out) |
|
72 |
self.failUnless(err.startswith( |
|
73 |
'bzr: ERROR: exceptions.OSError: '
|
|
74 |
'[Errno 2] No such file or directory: ')) |
|
75 |
||
76 |
os.mkdir('subdir2') |
|
77 |
out, err = self.run_bzr('init', 'subdir2') |
|
78 |
self.assertEqual('', out) |
|
79 |
self.assertEqual('', err) |
|
80 |
# init an existing branch.
|
|
81 |
out, err = self.run_bzr('init', 'subdir2', retcode=3) |
|
82 |
self.assertEqual('', out) |
|
83 |
self.failUnless(err.startswith('bzr: ERROR: Already a branch:')) |