35
35
def test_init_with_format(self):
36
36
# Verify bzr init --format constructs something plausible
37
37
t = self.get_transport()
38
self.runbzr('init --format default')
38
self.run_bzr('init --format default')
39
39
self.assertIsDirectory('.bzr', t)
40
40
self.assertIsDirectory('.bzr/checkout', t)
41
41
self.assertIsDirectory('.bzr/checkout/lock', t)
43
43
def test_init_weave(self):
44
44
# --format=weave should be accepted to allow interoperation with
45
45
# old releases when desired.
46
out, err = self.run_bzr('init', '--format=weave')
46
out, err = self.run_bzr('init --format=weave')
47
47
self.assertEqual('', out)
48
48
self.assertEqual('', err)
56
56
newdir = format.initialize(t.abspath('repo'))
57
57
repo = newdir.create_repository(shared=True)
58
58
repo.set_make_working_trees(False)
59
out, err = self.run_bzr('init', 'repo')
59
out, err = self.run_bzr('init repo')
60
60
self.assertEqual('', out)
61
61
self.assertEqual('', err)
62
62
newdir.open_branch()
68
68
self.assertEqual('', err)
70
70
# Can it handle subdirectories of branches too ?
71
out, err = self.run_bzr('init', 'subdir1')
71
out, err = self.run_bzr('init subdir1')
72
72
self.assertEqual('', out)
73
73
self.assertEqual('', err)
74
74
WorkingTree.open('subdir1')
76
76
self.run_bzr_error(['Parent directory of subdir2/nothere does not exist'],
77
'init', 'subdir2/nothere')
78
out, err = self.run_bzr('init', 'subdir2/nothere', retcode=3)
77
'init subdir2/nothere')
78
out, err = self.run_bzr('init subdir2/nothere', retcode=3)
79
79
self.assertEqual('', out)
81
81
os.mkdir('subdir2')
82
out, err = self.run_bzr('init', 'subdir2')
82
out, err = self.run_bzr('init subdir2')
83
83
self.assertEqual('', out)
84
84
self.assertEqual('', err)
85
85
# init an existing branch.
86
out, err = self.run_bzr('init', 'subdir2', retcode=3)
86
out, err = self.run_bzr('init subdir2', retcode=3)
87
87
self.assertEqual('', out)
88
88
self.failUnless(err.startswith('bzr: ERROR: Already a branch:'))
99
99
repo = self.make_repository('.', shared=True)
100
100
repo.set_make_working_trees(False)
101
101
# make a branch; by default without a working tree
102
self.run_bzr('init', 'subdir')
102
self.run_bzr('init subdir')
104
out, err = self.run_bzr('init', 'subdir', retcode=3)
104
out, err = self.run_bzr('init subdir', retcode=3)
105
105
# suggests using checkout
106
self.assertContainsRe(err, 'ontains a branch.*but no working tree.*checkout')
106
self.assertContainsRe(err,
107
'ontains a branch.*but no working tree.*checkout')
108
109
def test_no_defaults(self):
109
110
"""Init creates no default ignore rules."""
117
118
except UnicodeError:
118
119
raise TestSkipped("Unable to create Unicode filename")
119
120
# try to init unicode dir
120
self.run_bzr('init', u'mu-\xb5')
121
self.run_bzr(['init', u'mu-\xb5'])
122
123
def create_simple_tree(self):
123
124
tree = self.make_branch_and_tree('tree')
131
132
tree = self.create_simple_tree()
133
134
self.run_bzr_error(['Parent directory of ../new/tree does not exist'],
134
'init', '../new/tree',
136
self.run_bzr('init', '../new/tree', '--create-prefix',
135
'init ../new/tree', working_dir='tree')
136
self.run_bzr('init ../new/tree --create-prefix', working_dir='tree')
138
137
self.failUnlessExists('new/tree/.bzr')
143
142
def test_init(self):
144
143
# init on a remote url should succeed.
145
out, err = self.run_bzr('init', self.get_url())
144
out, err = self.run_bzr(['init', self.get_url()])
146
145
self.assertEqual('', out)
147
146
self.assertEqual('', err)
151
150
self.make_branch('.')
153
152
# rely on SFTPServer get_url() pointing at '.'
154
out, err = self.run_bzr_error(['Already a branch'], 'init', self.get_url())
153
out, err = self.run_bzr_error(['Already a branch'],
154
['init', self.get_url()])
156
156
# make sure using 'bzr checkout' is not suggested
157
157
# for remote locations missing a working tree
163
163
self.make_branch_and_tree('.')
165
165
# rely on SFTPServer get_url() pointing at '.'
166
self.run_bzr_error(['Already a branch'], 'init', self.get_url())
166
self.run_bzr_error(['Already a branch'], ['init', self.get_url()])
168
168
def test_init_append_revisions_only(self):
169
self.run_bzr('init', '--dirstate-tags', 'normal_branch6')
169
self.run_bzr('init --dirstate-tags normal_branch6')
170
170
branch = _mod_branch.Branch.open('normal_branch6')
171
171
self.assertEqual(False, branch._get_append_revisions_only())
172
self.run_bzr('init', '--append-revisions-only',
173
'--dirstate-tags', 'branch6')
172
self.run_bzr('init --append-revisions-only --dirstate-tags branch6')
174
173
branch = _mod_branch.Branch.open('branch6')
175
174
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')
175
self.run_bzr_error(['cannot be set to append-revisions-only'],
176
'init --append-revisions-only --knit knit')