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
 | 
| 
1887.1.1
by Adeodato Simó
 Do not separate paragraphs in the copyright statement with blank lines,  | 
2  | 
#
 | 
| 
1553.5.78
by Martin Pool
 New bzr init --format option and test  | 
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.
 | 
|
| 
1887.1.1
by Adeodato Simó
 Do not separate paragraphs in the copyright statement with blank lines,  | 
7  | 
#
 | 
| 
1553.5.78
by Martin Pool
 New bzr init --format option and test  | 
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.
 | 
|
| 
1887.1.1
by Adeodato Simó
 Do not separate paragraphs in the copyright statement with blank lines,  | 
12  | 
#
 | 
| 
1553.5.78
by Martin Pool
 New bzr init --format option and test  | 
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  | 
| 
1662.1.19
by Martin Pool
 Better error message when initting existing tree  | 
21  | 
import re  | 
| 
1553.5.78
by Martin Pool
 New bzr init --format option and test  | 
22  | 
|
| 
1654.1.4
by Robert Collins
 Teach `bzr init` how to init at the root of a repository.  | 
23  | 
from bzrlib.bzrdir import BzrDirMetaFormat1  | 
| 
1553.5.78
by Martin Pool
 New bzr init --format option and test  | 
24  | 
from bzrlib.tests.blackbox import ExternalBase  | 
| 
1830.4.1
by Wouter van Heyst
 Allow bzr init to create remote branches  | 
25  | 
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer  | 
| 
1654.1.4
by Robert Collins
 Teach `bzr init` how to init at the root of a repository.  | 
26  | 
from bzrlib.workingtree import WorkingTree  | 
| 
1553.5.78
by Martin Pool
 New bzr init --format option and test  | 
27  | 
|
28  | 
||
29  | 
class TestInit(ExternalBase):  | 
|
30  | 
||
31  | 
def test_init_with_format(self):  | 
|
| 
1666.1.3
by Robert Collins
 Fix and test upgrades from bzrdir 6 over SFTP.  | 
32  | 
        # Verify bzr init --format constructs something plausible
 | 
| 
1553.5.78
by Martin Pool
 New bzr init --format option and test  | 
33  | 
t = self.get_transport()  | 
| 
1694.2.6
by Martin Pool
 [merge] bzr.dev  | 
34  | 
self.runbzr('init --format default')  | 
| 
1553.5.78
by Martin Pool
 New bzr init --format option and test  | 
35  | 
self.assertIsDirectory('.bzr', t)  | 
36  | 
self.assertIsDirectory('.bzr/checkout', t)  | 
|
37  | 
self.assertIsDirectory('.bzr/checkout/lock', t)  | 
|
| 
1654.1.4
by Robert Collins
 Teach `bzr init` how to init at the root of a repository.  | 
38  | 
|
| 
1666.1.3
by Robert Collins
 Fix and test upgrades from bzrdir 6 over SFTP.  | 
39  | 
def test_init_weave(self):  | 
40  | 
        # --format=weave should be accepted to allow interoperation with
 | 
|
41  | 
        # old releases when desired.
 | 
|
42  | 
out, err = self.run_bzr('init', '--format=weave')  | 
|
43  | 
self.assertEqual('', out)  | 
|
44  | 
self.assertEqual('', err)  | 
|
45  | 
||
| 
1654.1.4
by Robert Collins
 Teach `bzr init` how to init at the root of a repository.  | 
46  | 
def test_init_at_repository_root(self):  | 
47  | 
        # bzr init at the root of a repository should create a branch
 | 
|
48  | 
        # and working tree even when creation of working trees is disabled.
 | 
|
49  | 
t = self.get_transport()  | 
|
50  | 
t.mkdir('repo')  | 
|
51  | 
format = BzrDirMetaFormat1()  | 
|
52  | 
newdir = format.initialize(t.abspath('repo'))  | 
|
53  | 
repo = newdir.create_repository(shared=True)  | 
|
54  | 
repo.set_make_working_trees(False)  | 
|
55  | 
out, err = self.run_bzr('init', 'repo')  | 
|
56  | 
self.assertEqual('', out)  | 
|
57  | 
self.assertEqual('', err)  | 
|
58  | 
newdir.open_branch()  | 
|
59  | 
newdir.open_workingtree()  | 
|
60  | 
||
61  | 
def test_init_branch(self):  | 
|
62  | 
out, err = self.run_bzr('init')  | 
|
63  | 
self.assertEqual('', out)  | 
|
64  | 
self.assertEqual('', err)  | 
|
65  | 
||
66  | 
        # Can it handle subdirectories of branches too ?
 | 
|
67  | 
out, err = self.run_bzr('init', 'subdir1')  | 
|
68  | 
self.assertEqual('', out)  | 
|
69  | 
self.assertEqual('', err)  | 
|
70  | 
WorkingTree.open('subdir1')  | 
|
71  | 
||
72  | 
out, err = self.run_bzr('init', 'subdir2/nothere', retcode=3)  | 
|
73  | 
self.assertEqual('', out)  | 
|
| 
1740.5.3
by Martin Pool
 Cleanup more exception-formatting code  | 
74  | 
self.assertContainsRe(err,  | 
| 
1740.5.6
by Martin Pool
 Clean up many exception classes.  | 
75  | 
r'^bzr: ERROR: .*'  | 
| 
1740.5.3
by Martin Pool
 Cleanup more exception-formatting code  | 
76  | 
'\[Errno 2\] No such file or directory: ')  | 
| 
1654.1.4
by Robert Collins
 Teach `bzr init` how to init at the root of a repository.  | 
77  | 
|
78  | 
os.mkdir('subdir2')  | 
|
79  | 
out, err = self.run_bzr('init', 'subdir2')  | 
|
80  | 
self.assertEqual('', out)  | 
|
81  | 
self.assertEqual('', err)  | 
|
82  | 
        # init an existing branch.
 | 
|
83  | 
out, err = self.run_bzr('init', 'subdir2', retcode=3)  | 
|
84  | 
self.assertEqual('', out)  | 
|
85  | 
self.failUnless(err.startswith('bzr: ERROR: Already a branch:'))  | 
|
| 
1662.1.19
by Martin Pool
 Better error message when initting existing tree  | 
86  | 
|
87  | 
def test_init_existing_branch(self):  | 
|
88  | 
self.run_bzr('init')  | 
|
89  | 
out, err = self.run_bzr('init', retcode=3)  | 
|
90  | 
self.assertContainsRe(err, 'Already a branch')  | 
|
91  | 
        # don't suggest making a checkout, there's already a working tree
 | 
|
92  | 
self.assertFalse(re.search(r'checkout', err))  | 
|
93  | 
||
94  | 
def test_init_existing_without_workingtree(self):  | 
|
95  | 
        # make a repository
 | 
|
96  | 
self.run_bzr('init-repo', '.')  | 
|
97  | 
        # make a branch; by default without a working tree
 | 
|
98  | 
self.run_bzr('init', 'subdir')  | 
|
99  | 
        # fail
 | 
|
100  | 
out, err = self.run_bzr('init', 'subdir', retcode=3)  | 
|
101  | 
        # suggests using checkout
 | 
|
102  | 
self.assertContainsRe(err, 'ontains a branch.*but no working tree.*checkout')  | 
|
103  | 
||
| 
1765.1.1
by Robert Collins
 Remove the default ignores list from bzr, lowering the minimum overhead in bzr add.  | 
104  | 
def test_no_defaults(self):  | 
105  | 
"""Init creates no default ignore rules."""  | 
|
106  | 
self.run_bzr('init')  | 
|
107  | 
self.assertFalse(os.path.exists('.bzrignore'))  | 
|
| 
1830.4.1
by Wouter van Heyst
 Allow bzr init to create remote branches  | 
108  | 
|
| 
1830.4.7
by Wouter van Heyst
 review fixes, rename transport variable to to_transport  | 
109  | 
|
| 
1830.4.1
by Wouter van Heyst
 Allow bzr init to create remote branches  | 
110  | 
class TestSFTPInit(TestCaseWithSFTPServer):  | 
111  | 
||
112  | 
def test_init(self):  | 
|
| 
1830.4.3
by Wouter van Heyst
 more review comments  | 
113  | 
        # init on a remote url should succeed.
 | 
114  | 
out, err = self.run_bzr('init', self.get_url())  | 
|
| 
1830.4.1
by Wouter van Heyst
 Allow bzr init to create remote branches  | 
115  | 
self.assertEqual('', out)  | 
116  | 
self.assertEqual('', err)  | 
|
| 
1830.4.3
by Wouter van Heyst
 more review comments  | 
117  | 
|
118  | 
def test_init_existing_branch(self):  | 
|
119  | 
        # when there is already a branch present, make mention
 | 
|
| 
1830.4.4
by Wouter van Heyst
 more review comments  | 
120  | 
self.make_branch('.')  | 
121  | 
||
122  | 
        # rely on SFTPServer get_url() pointing at '.'
 | 
|
| 
1830.4.7
by Wouter van Heyst
 review fixes, rename transport variable to to_transport  | 
123  | 
out, err = self.run_bzr_error(['Already a branch'], 'init', self.get_url())  | 
| 
1830.4.5
by Wouter van Heyst
 cleanup  | 
124  | 
|
125  | 
        # make sure using 'bzr checkout' is not suggested
 | 
|
126  | 
        # for remote locations missing a working tree
 | 
|
127  | 
self.assertFalse(re.search(r'checkout', err))  | 
|
| 
1830.4.1
by Wouter van Heyst
 Allow bzr init to create remote branches  | 
128  | 
|
| 
1830.4.4
by Wouter van Heyst
 more review comments  | 
129  | 
def test_init_existing_branch_with_workingtree(self):  | 
| 
1830.4.3
by Wouter van Heyst
 more review comments  | 
130  | 
        # don't distinguish between the branch having a working tree or not
 | 
131  | 
        # when the branch itself is remote.
 | 
|
132  | 
self.make_branch_and_tree('.')  | 
|
133  | 
||
134  | 
        # rely on SFTPServer get_url() pointing at '.'
 | 
|
| 
1830.4.5
by Wouter van Heyst
 cleanup  | 
135  | 
self.run_bzr_error(['Already a branch'], 'init', self.get_url())  |