49
39
def test_init_weave(self):
50
40
# --format=weave should be accepted to allow interoperation with
51
41
# old releases when desired.
52
out, err = self.run_bzr('init --format=weave')
53
self.assertEqual("""Created a standalone tree (format: weave)\n""",
55
self.assertEqual('', err)
57
def test_init_format_2a(self):
58
"""Smoke test for constructing a format 2a repoistory."""
59
out, err = self.run_bzr('init --format=2a')
60
self.assertEqual("""Created a standalone tree (format: 2a)\n""",
42
out, err = self.run_bzr('init', '--format=weave')
43
self.assertEqual('', out)
62
44
self.assertEqual('', err)
64
46
def test_init_at_repository_root(self):
70
52
newdir = format.initialize(t.abspath('repo'))
71
53
repo = newdir.create_repository(shared=True)
72
54
repo.set_make_working_trees(False)
73
out, err = self.run_bzr('init repo')
74
self.assertEqual("""Created a repository tree (format: %s)
75
Using shared repository: %s
76
""" % (self._default_label, urlutils.local_path_from_url(
77
repo.bzrdir.root_transport.external_url())), out)
78
cwd = osutils.getcwd()
79
self.assertEndsWith(out, cwd + '/repo/\n')
55
out, err = self.run_bzr('init', 'repo')
56
self.assertEqual('', out)
80
57
self.assertEqual('', err)
81
58
newdir.open_branch()
82
59
newdir.open_workingtree()
84
61
def test_init_branch(self):
85
62
out, err = self.run_bzr('init')
86
self.assertEqual("Created a standalone tree (format: %s)\n" % (
87
self._default_label,), out)
63
self.assertEqual('', out)
88
64
self.assertEqual('', err)
90
66
# Can it handle subdirectories of branches too ?
91
out, err = self.run_bzr('init subdir1')
92
self.assertEqual("Created a standalone tree (format: %s)\n" % (
93
self._default_label,), out)
67
out, err = self.run_bzr('init', 'subdir1')
68
self.assertEqual('', out)
94
69
self.assertEqual('', err)
95
70
WorkingTree.open('subdir1')
97
self.run_bzr_error(['Parent directory of subdir2/nothere does not exist'],
98
'init subdir2/nothere')
99
out, err = self.run_bzr('init subdir2/nothere', retcode=3)
72
out, err = self.run_bzr('init', 'subdir2/nothere', retcode=3)
100
73
self.assertEqual('', out)
74
self.assertContainsRe(err,
76
'\[Errno 2\] No such file or directory: ')
102
78
os.mkdir('subdir2')
103
out, err = self.run_bzr('init subdir2')
104
self.assertEqual("Created a standalone tree (format: %s)\n" % (
105
self._default_label,), out)
79
out, err = self.run_bzr('init', 'subdir2')
80
self.assertEqual('', out)
106
81
self.assertEqual('', err)
107
82
# init an existing branch.
108
out, err = self.run_bzr('init subdir2', retcode=3)
83
out, err = self.run_bzr('init', 'subdir2', retcode=3)
109
84
self.assertEqual('', out)
110
85
self.failUnless(err.startswith('bzr: ERROR: Already a branch:'))
112
def test_init_branch_quiet(self):
113
out, err = self.run_bzr('init -q')
114
self.assertEqual('', out)
115
self.assertEqual('', err)
117
87
def test_init_existing_branch(self):
118
88
self.run_bzr('init')
119
89
out, err = self.run_bzr('init', retcode=3)
124
94
def test_init_existing_without_workingtree(self):
125
95
# make a repository
126
repo = self.make_repository('.', shared=True)
127
repo.set_make_working_trees(False)
96
self.run_bzr('init-repo', '.')
128
97
# make a branch; by default without a working tree
129
self.run_bzr('init subdir')
98
self.run_bzr('init', 'subdir')
131
out, err = self.run_bzr('init subdir', retcode=3)
100
out, err = self.run_bzr('init', 'subdir', retcode=3)
132
101
# suggests using checkout
133
self.assertContainsRe(err,
134
'ontains a branch.*but no working tree.*checkout')
102
self.assertContainsRe(err, 'ontains a branch.*but no working tree.*checkout')
136
104
def test_no_defaults(self):
137
105
"""Init creates no default ignore rules."""
138
106
self.run_bzr('init')
139
107
self.assertFalse(os.path.exists('.bzrignore'))
141
def test_init_unicode(self):
142
# Make sure getcwd can handle unicode filenames
146
raise TestSkipped("Unable to create Unicode filename")
147
# try to init unicode dir
148
self.run_bzr(['init', '-q', u'mu-\xb5'])
150
def create_simple_tree(self):
151
tree = self.make_branch_and_tree('tree')
152
self.build_tree(['tree/a'])
153
tree.add(['a'], ['a-id'])
154
tree.commit('one', rev_id='r1')
157
def test_init_create_prefix(self):
158
"""'bzr init --create-prefix; will create leading directories."""
159
tree = self.create_simple_tree()
161
self.run_bzr_error(['Parent directory of ../new/tree does not exist'],
162
'init ../new/tree', working_dir='tree')
163
self.run_bzr('init ../new/tree --create-prefix', working_dir='tree')
164
self.failUnlessExists('new/tree/.bzr')
167
110
class TestSFTPInit(TestCaseWithSFTPServer):
169
112
def test_init(self):
170
113
# init on a remote url should succeed.
171
out, err = self.run_bzr(['init', '--pack-0.92', self.get_url()])
172
self.assertEqual(out,
173
"""Created a standalone branch (format: pack-0.92)\n""")
114
out, err = self.run_bzr('init', self.get_url())
115
self.assertEqual('', out)
174
116
self.assertEqual('', err)
176
118
def test_init_existing_branch(self):
177
119
# when there is already a branch present, make mention
178
120
self.make_branch('.')
180
122
# rely on SFTPServer get_url() pointing at '.'
181
out, err = self.run_bzr_error(['Already a branch'],
182
['init', self.get_url()])
123
out, err = self.run_bzr_error(['Already a branch'], 'init', self.get_url())
184
125
# make sure using 'bzr checkout' is not suggested
185
126
# for remote locations missing a working tree
186
self.assertFalse(re.search(r'use bzr checkout', err))
127
self.assertFalse(re.search(r'checkout', err))
188
129
def test_init_existing_branch_with_workingtree(self):
189
130
# don't distinguish between the branch having a working tree or not
191
132
self.make_branch_and_tree('.')
193
134
# rely on SFTPServer get_url() pointing at '.'
194
self.run_bzr_error(['Already a branch'], ['init', self.get_url()])
196
def test_init_append_revisions_only(self):
197
self.run_bzr('init --dirstate-tags normal_branch6')
198
branch = _mod_branch.Branch.open('normal_branch6')
199
self.assertEqual(False, branch._get_append_revisions_only())
200
self.run_bzr('init --append-revisions-only --dirstate-tags branch6')
201
branch = _mod_branch.Branch.open('branch6')
202
self.assertEqual(True, branch._get_append_revisions_only())
203
self.run_bzr_error(['cannot be set to append-revisions-only'],
204
'init --append-revisions-only --knit knit')
135
self.run_bzr_error(['Already a branch'], 'init', self.get_url())