13
13
# You should have received a copy of the GNU General Public License
14
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
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
18
"""Test "bzr init"""
44
50
# --format=weave should be accepted to allow interoperation with
45
51
# old releases when desired.
46
52
out, err = self.run_bzr('init --format=weave')
47
self.assertEqual("""Standalone tree (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""",
51
62
self.assertEqual('', err)
53
64
def test_init_at_repository_root(self):
60
71
repo = newdir.create_repository(shared=True)
61
72
repo.set_make_working_trees(False)
62
73
out, err = self.run_bzr('init repo')
64
"""Repository tree (format: pack-0.92)
66
shared repository: repo
67
repository branch: 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')
69
80
self.assertEqual('', err)
70
81
newdir.open_branch()
71
82
newdir.open_workingtree()
73
84
def test_init_branch(self):
74
85
out, err = self.run_bzr('init')
76
"""Standalone tree (format: pack-0.92)
86
self.assertEqual("Created a standalone tree (format: %s)\n" % (
87
self._default_label,), out)
80
88
self.assertEqual('', err)
82
90
# Can it handle subdirectories of branches too ?
83
91
out, err = self.run_bzr('init subdir1')
85
"""Standalone tree (format: pack-0.92)
92
self.assertEqual("Created a standalone tree (format: %s)\n" % (
93
self._default_label,), out)
89
94
self.assertEqual('', err)
90
95
WorkingTree.open('subdir1')
92
97
self.run_bzr_error(['Parent directory of subdir2/nothere does not exist'],
93
98
'init subdir2/nothere')
94
99
out, err = self.run_bzr('init subdir2/nothere', retcode=3)
95
100
self.assertEqual('', out)
97
102
os.mkdir('subdir2')
98
103
out, err = self.run_bzr('init subdir2')
99
self.assertEqual("""Standalone tree (format: pack-0.92)
104
self.assertEqual("Created a standalone tree (format: %s)\n" % (
105
self._default_label,), out)
103
106
self.assertEqual('', err)
104
107
# init an existing branch.
105
108
out, err = self.run_bzr('init subdir2', retcode=3)
142
145
except UnicodeError:
143
146
raise TestSkipped("Unable to create Unicode filename")
144
147
# try to init unicode dir
145
self.run_bzr(['init', u'mu-\xb5'])
148
self.run_bzr(['init', '-q', u'mu-\xb5'])
147
150
def create_simple_tree(self):
148
151
tree = self.make_branch_and_tree('tree')
166
169
def test_init(self):
167
170
# init on a remote url should succeed.
168
out, err = self.run_bzr(['init', self.get_url()])
169
self.assertStartsWith(out, """Standalone branch (format: pack-0.92)
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""")
172
174
self.assertEqual('', err)
174
176
def test_init_existing_branch(self):
175
177
# when there is already a branch present, make mention
176
178
self.make_branch('.')