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