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"""
50
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""",
62
self.assertEqual('', err)
52
64
def test_init_at_repository_root(self):
53
65
# bzr init at the root of a repository should create a branch
54
66
# and working tree even when creation of working trees is disabled.
59
71
repo = newdir.create_repository(shared=True)
60
72
repo.set_make_working_trees(False)
61
73
out, err = self.run_bzr('init repo')
62
self.assertEqual("""Created a repository tree (format: pack-0.92)
74
self.assertEqual("""Created a repository tree (format: %s)
63
75
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")
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')
68
80
self.assertEqual('', err)
69
81
newdir.open_branch()
70
82
newdir.open_workingtree()
72
84
def test_init_branch(self):
73
85
out, err = self.run_bzr('init')
74
self.assertEqual("""Created a standalone tree (format: pack-0.92)\n""",
86
self.assertEqual("Created a standalone tree (format: %s)\n" % (
87
self._default_label,), out)
76
88
self.assertEqual('', err)
78
90
# Can it handle subdirectories of branches too ?
79
91
out, err = self.run_bzr('init subdir1')
80
self.assertEqual("""Created a standalone tree (format: pack-0.92)\n""",
92
self.assertEqual("Created a standalone tree (format: %s)\n" % (
93
self._default_label,), out)
82
94
self.assertEqual('', err)
83
95
WorkingTree.open('subdir1')
85
97
self.run_bzr_error(['Parent directory of subdir2/nothere does not exist'],
86
98
'init subdir2/nothere')
87
99
out, err = self.run_bzr('init subdir2/nothere', retcode=3)
88
100
self.assertEqual('', out)
90
102
os.mkdir('subdir2')
91
103
out, err = self.run_bzr('init subdir2')
92
self.assertEqual("""Created a standalone tree (format: pack-0.92)\n""",
104
self.assertEqual("Created a standalone tree (format: %s)\n" % (
105
self._default_label,), out)
94
106
self.assertEqual('', err)
95
107
# init an existing branch.
96
108
out, err = self.run_bzr('init subdir2', retcode=3)
157
169
def test_init(self):
158
170
# init on a remote url should succeed.
159
out, err = self.run_bzr(['init', self.get_url()])
171
out, err = self.run_bzr(['init', '--pack-0.92', self.get_url()])
160
172
self.assertEqual(out,
161
173
"""Created a standalone branch (format: pack-0.92)\n""")
162
174
self.assertEqual('', err)