1
1
# Copyright (C) 2006 by Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
11
# GNU General Public License for more details.
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
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
72
71
out, err = self.run_bzr('init', 'subdir2/nothere', retcode=3)
73
72
self.assertEqual('', out)
74
self.assertContainsRe(err,
76
'\[Errno 2\] No such file or directory: ')
73
self.failUnless(err.startswith(
74
'bzr: ERROR: exceptions.OSError: '
75
'[Errno 2] No such file or directory: '))
78
77
os.mkdir('subdir2')
79
78
out, err = self.run_bzr('init', 'subdir2')
101
100
# suggests using checkout
102
101
self.assertContainsRe(err, 'ontains a branch.*but no working tree.*checkout')
104
def test_no_defaults(self):
105
"""Init creates no default ignore rules."""
107
self.assertFalse(os.path.exists('.bzrignore'))
110
class TestSFTPInit(TestCaseWithSFTPServer):
113
# init on a remote url should succeed.
114
out, err = self.run_bzr('init', self.get_url())
115
self.assertEqual('', out)
116
self.assertEqual('', err)
118
def test_init_existing_branch(self):
119
# when there is already a branch present, make mention
120
self.make_branch('.')
122
# rely on SFTPServer get_url() pointing at '.'
123
out, err = self.run_bzr_error(['Already a branch'], 'init', self.get_url())
125
# make sure using 'bzr checkout' is not suggested
126
# for remote locations missing a working tree
127
self.assertFalse(re.search(r'checkout', err))
129
def test_init_existing_branch_with_workingtree(self):
130
# don't distinguish between the branch having a working tree or not
131
# when the branch itself is remote.
132
self.make_branch_and_tree('.')
134
# rely on SFTPServer get_url() pointing at '.'
135
self.run_bzr_error(['Already a branch'], 'init', self.get_url())