bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
| 
2257.2.2
by Wouter van Heyst
 Actually test that `bzr init-repo --{no,}-trees` still works  | 
1  | 
# Copyright (C) 2006, 2007 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  | 
|
| 
2230.3.42
by Aaron Bentley
 add --append-revisions-only option to init  | 
23  | 
from bzrlib import (  | 
24  | 
branch as _mod_branch,  | 
|
25  | 
    )
 | 
|
| 
1654.1.4
by Robert Collins
 Teach `bzr init` how to init at the root of a repository.  | 
26  | 
from bzrlib.bzrdir import BzrDirMetaFormat1  | 
| 
2294.2.1
by Alexander Belchenko
 Bugfix #85599: ``bzr init`` works with unicode argument LOCATION  | 
27  | 
from bzrlib.tests import TestSkipped  | 
| 
1553.5.78
by Martin Pool
 New bzr init --format option and test  | 
28  | 
from bzrlib.tests.blackbox import ExternalBase  | 
| 
1830.4.1
by Wouter van Heyst
 Allow bzr init to create remote branches  | 
29  | 
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.  | 
30  | 
from bzrlib.workingtree import WorkingTree  | 
| 
1553.5.78
by Martin Pool
 New bzr init --format option and test  | 
31  | 
|
32  | 
||
33  | 
class TestInit(ExternalBase):  | 
|
34  | 
||
35  | 
def test_init_with_format(self):  | 
|
| 
1666.1.3
by Robert Collins
 Fix and test upgrades from bzrdir 6 over SFTP.  | 
36  | 
        # Verify bzr init --format constructs something plausible
 | 
| 
1553.5.78
by Martin Pool
 New bzr init --format option and test  | 
37  | 
t = self.get_transport()  | 
| 
1857.1.20
by Aaron Bentley
 Strip out all the EnumOption stuff  | 
38  | 
self.runbzr('init --format default')  | 
| 
1553.5.78
by Martin Pool
 New bzr init --format option and test  | 
39  | 
self.assertIsDirectory('.bzr', t)  | 
40  | 
self.assertIsDirectory('.bzr/checkout', t)  | 
|
41  | 
self.assertIsDirectory('.bzr/checkout/lock', t)  | 
|
| 
1654.1.4
by Robert Collins
 Teach `bzr init` how to init at the root of a repository.  | 
42  | 
|
| 
1666.1.3
by Robert Collins
 Fix and test upgrades from bzrdir 6 over SFTP.  | 
43  | 
def test_init_weave(self):  | 
| 
1857.1.20
by Aaron Bentley
 Strip out all the EnumOption stuff  | 
44  | 
        # --format=weave should be accepted to allow interoperation with
 | 
| 
1666.1.3
by Robert Collins
 Fix and test upgrades from bzrdir 6 over SFTP.  | 
45  | 
        # old releases when desired.
 | 
| 
1857.1.20
by Aaron Bentley
 Strip out all the EnumOption stuff  | 
46  | 
out, err = self.run_bzr('init', '--format=weave')  | 
| 
1666.1.3
by Robert Collins
 Fix and test upgrades from bzrdir 6 over SFTP.  | 
47  | 
self.assertEqual('', out)  | 
48  | 
self.assertEqual('', err)  | 
|
49  | 
||
| 
1654.1.4
by Robert Collins
 Teach `bzr init` how to init at the root of a repository.  | 
50  | 
def test_init_at_repository_root(self):  | 
51  | 
        # bzr init at the root of a repository should create a branch
 | 
|
52  | 
        # and working tree even when creation of working trees is disabled.
 | 
|
53  | 
t = self.get_transport()  | 
|
54  | 
t.mkdir('repo')  | 
|
55  | 
format = BzrDirMetaFormat1()  | 
|
56  | 
newdir = format.initialize(t.abspath('repo'))  | 
|
57  | 
repo = newdir.create_repository(shared=True)  | 
|
58  | 
repo.set_make_working_trees(False)  | 
|
59  | 
out, err = self.run_bzr('init', 'repo')  | 
|
60  | 
self.assertEqual('', out)  | 
|
61  | 
self.assertEqual('', err)  | 
|
62  | 
newdir.open_branch()  | 
|
63  | 
newdir.open_workingtree()  | 
|
64  | 
||
65  | 
def test_init_branch(self):  | 
|
66  | 
out, err = self.run_bzr('init')  | 
|
67  | 
self.assertEqual('', out)  | 
|
68  | 
self.assertEqual('', err)  | 
|
69  | 
||
70  | 
        # Can it handle subdirectories of branches too ?
 | 
|
71  | 
out, err = self.run_bzr('init', 'subdir1')  | 
|
72  | 
self.assertEqual('', out)  | 
|
73  | 
self.assertEqual('', err)  | 
|
74  | 
WorkingTree.open('subdir1')  | 
|
75  | 
||
| 
2524.1.1
by Aaron Bentley
 Revert broken changes  | 
76  | 
self.run_bzr_error(['Parent directory of subdir2/nothere does not exist'],  | 
77  | 
'init', 'subdir2/nothere')  | 
|
| 
1654.1.4
by Robert Collins
 Teach `bzr init` how to init at the root of a repository.  | 
78  | 
out, err = self.run_bzr('init', 'subdir2/nothere', retcode=3)  | 
79  | 
self.assertEqual('', out)  | 
|
80  | 
||
81  | 
os.mkdir('subdir2')  | 
|
82  | 
out, err = self.run_bzr('init', 'subdir2')  | 
|
83  | 
self.assertEqual('', out)  | 
|
84  | 
self.assertEqual('', err)  | 
|
85  | 
        # init an existing branch.
 | 
|
86  | 
out, err = self.run_bzr('init', 'subdir2', retcode=3)  | 
|
87  | 
self.assertEqual('', out)  | 
|
88  | 
self.failUnless(err.startswith('bzr: ERROR: Already a branch:'))  | 
|
| 
1662.1.19
by Martin Pool
 Better error message when initting existing tree  | 
89  | 
|
90  | 
def test_init_existing_branch(self):  | 
|
91  | 
self.run_bzr('init')  | 
|
92  | 
out, err = self.run_bzr('init', retcode=3)  | 
|
93  | 
self.assertContainsRe(err, 'Already a branch')  | 
|
94  | 
        # don't suggest making a checkout, there's already a working tree
 | 
|
95  | 
self.assertFalse(re.search(r'checkout', err))  | 
|
96  | 
||
97  | 
def test_init_existing_without_workingtree(self):  | 
|
98  | 
        # make a repository
 | 
|
| 
2257.2.1
by Wouter van Heyst
 Change the ui level default for init-repo to --trees.  | 
99  | 
repo = self.make_repository('.', shared=True)  | 
100  | 
repo.set_make_working_trees(False)  | 
|
| 
1662.1.19
by Martin Pool
 Better error message when initting existing tree  | 
101  | 
        # make a branch; by default without a working tree
 | 
102  | 
self.run_bzr('init', 'subdir')  | 
|
103  | 
        # fail
 | 
|
104  | 
out, err = self.run_bzr('init', 'subdir', retcode=3)  | 
|
105  | 
        # suggests using checkout
 | 
|
106  | 
self.assertContainsRe(err, 'ontains a branch.*but no working tree.*checkout')  | 
|
107  | 
||
| 
1765.1.1
by Robert Collins
 Remove the default ignores list from bzr, lowering the minimum overhead in bzr add.  | 
108  | 
def test_no_defaults(self):  | 
109  | 
"""Init creates no default ignore rules."""  | 
|
110  | 
self.run_bzr('init')  | 
|
111  | 
self.assertFalse(os.path.exists('.bzrignore'))  | 
|
| 
1830.4.1
by Wouter van Heyst
 Allow bzr init to create remote branches  | 
112  | 
|
| 
2294.2.1
by Alexander Belchenko
 Bugfix #85599: ``bzr init`` works with unicode argument LOCATION  | 
113  | 
def test_init_unicode(self):  | 
114  | 
        # Make sure getcwd can handle unicode filenames
 | 
|
115  | 
try:  | 
|
116  | 
os.mkdir(u'mu-\xb5')  | 
|
117  | 
except UnicodeError:  | 
|
118  | 
raise TestSkipped("Unable to create Unicode filename")  | 
|
119  | 
        # try to init unicode dir
 | 
|
120  | 
self.run_bzr('init', u'mu-\xb5')  | 
|
121  | 
||
| 
2524.1.1
by Aaron Bentley
 Revert broken changes  | 
122  | 
def create_simple_tree(self):  | 
123  | 
tree = self.make_branch_and_tree('tree')  | 
|
124  | 
self.build_tree(['tree/a'])  | 
|
125  | 
tree.add(['a'], ['a-id'])  | 
|
126  | 
tree.commit('one', rev_id='r1')  | 
|
127  | 
return tree  | 
|
128  | 
||
129  | 
def test_init_create_prefix(self):  | 
|
130  | 
"""'bzr init --create-prefix; will create leading directories."""  | 
|
131  | 
tree = self.create_simple_tree()  | 
|
132  | 
||
133  | 
self.run_bzr_error(['Parent directory of ../new/tree does not exist'],  | 
|
134  | 
'init', '../new/tree',  | 
|
135  | 
working_dir='tree')  | 
|
136  | 
self.run_bzr('init', '../new/tree', '--create-prefix',  | 
|
137  | 
working_dir='tree')  | 
|
138  | 
self.failUnlessExists('new/tree/.bzr')  | 
|
139  | 
||
| 
1830.4.7
by Wouter van Heyst
 review fixes, rename transport variable to to_transport  | 
140  | 
|
| 
1830.4.1
by Wouter van Heyst
 Allow bzr init to create remote branches  | 
141  | 
class TestSFTPInit(TestCaseWithSFTPServer):  | 
142  | 
||
143  | 
def test_init(self):  | 
|
| 
1830.4.3
by Wouter van Heyst
 more review comments  | 
144  | 
        # init on a remote url should succeed.
 | 
145  | 
out, err = self.run_bzr('init', self.get_url())  | 
|
| 
1830.4.1
by Wouter van Heyst
 Allow bzr init to create remote branches  | 
146  | 
self.assertEqual('', out)  | 
147  | 
self.assertEqual('', err)  | 
|
| 
1830.4.3
by Wouter van Heyst
 more review comments  | 
148  | 
|
149  | 
def test_init_existing_branch(self):  | 
|
150  | 
        # when there is already a branch present, make mention
 | 
|
| 
1830.4.4
by Wouter van Heyst
 more review comments  | 
151  | 
self.make_branch('.')  | 
152  | 
||
153  | 
        # rely on SFTPServer get_url() pointing at '.'
 | 
|
| 
1830.4.7
by Wouter van Heyst
 review fixes, rename transport variable to to_transport  | 
154  | 
out, err = self.run_bzr_error(['Already a branch'], 'init', self.get_url())  | 
| 
1830.4.5
by Wouter van Heyst
 cleanup  | 
155  | 
|
156  | 
        # make sure using 'bzr checkout' is not suggested
 | 
|
157  | 
        # for remote locations missing a working tree
 | 
|
| 
2264.1.1
by Martin Pool
 make TestSFTPInit.test_init_existing_branch less fragile (jamesw)  | 
158  | 
self.assertFalse(re.search(r'use bzr checkout', err))  | 
| 
1830.4.1
by Wouter van Heyst
 Allow bzr init to create remote branches  | 
159  | 
|
| 
1830.4.4
by Wouter van Heyst
 more review comments  | 
160  | 
def test_init_existing_branch_with_workingtree(self):  | 
| 
1830.4.3
by Wouter van Heyst
 more review comments  | 
161  | 
        # don't distinguish between the branch having a working tree or not
 | 
162  | 
        # when the branch itself is remote.
 | 
|
163  | 
self.make_branch_and_tree('.')  | 
|
164  | 
||
165  | 
        # rely on SFTPServer get_url() pointing at '.'
 | 
|
| 
1830.4.5
by Wouter van Heyst
 cleanup  | 
166  | 
self.run_bzr_error(['Already a branch'], 'init', self.get_url())  | 
| 
2230.3.42
by Aaron Bentley
 add --append-revisions-only option to init  | 
167  | 
|
168  | 
def test_init_append_revisions_only(self):  | 
|
| 
1551.13.1
by Aaron Bentley
 Introduce dirstate-tags format  | 
169  | 
self.run_bzr('init', '--dirstate-tags', 'normal_branch6')  | 
| 
2230.3.42
by Aaron Bentley
 add --append-revisions-only option to init  | 
170  | 
branch = _mod_branch.Branch.open('normal_branch6')  | 
171  | 
self.assertEqual(False, branch._get_append_revisions_only())  | 
|
172  | 
self.run_bzr('init', '--append-revisions-only',  | 
|
| 
1551.13.1
by Aaron Bentley
 Introduce dirstate-tags format  | 
173  | 
'--dirstate-tags', 'branch6')  | 
| 
2230.3.42
by Aaron Bentley
 add --append-revisions-only option to init  | 
174  | 
branch = _mod_branch.Branch.open('branch6')  | 
175  | 
self.assertEqual(True, branch._get_append_revisions_only())  | 
|
176  | 
self.run_bzr_error(['cannot be set to append-revisions-only'], 'init',  | 
|
177  | 
'--append-revisions-only', '--knit', 'knit')  |