/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_init.py

  • Committer: Martin Pool
  • Date: 2006-10-06 02:04:17 UTC
  • mfrom: (1908.10.1 bench_usecases.merge2)
  • mto: This revision was merged to the branch mainline in revision 2068.
  • Revision ID: mbp@sourcefrog.net-20061006020417-4949ca86f4417a4d
merge additional fix from cfbolz

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (C) 2006 by Canonical Ltd
2
 
 
 
2
#
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.
7
 
 
 
7
#
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.
12
 
 
 
12
#
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
18
18
"""Test "bzr init"""
19
19
 
20
20
import os
 
21
import re
21
22
 
22
23
from bzrlib.bzrdir import BzrDirMetaFormat1
23
24
from bzrlib.tests.blackbox import ExternalBase
 
25
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
24
26
from bzrlib.workingtree import WorkingTree
25
27
 
26
28
 
27
29
class TestInit(ExternalBase):
28
30
 
29
31
    def test_init_with_format(self):
30
 
        """Verify bzr init --format constructs something plausible"""
 
32
        # Verify bzr init --format constructs something plausible
31
33
        t = self.get_transport()
32
 
        self.runbzr('init --format metadir')
 
34
        self.runbzr('init --format default')
33
35
        self.assertIsDirectory('.bzr', t)
34
36
        self.assertIsDirectory('.bzr/checkout', t)
35
37
        self.assertIsDirectory('.bzr/checkout/lock', t)
36
38
 
 
39
    def test_init_weave(self):
 
40
        # --format=weave should be accepted to allow interoperation with
 
41
        # old releases when desired.
 
42
        out, err = self.run_bzr('init', '--format=weave')
 
43
        self.assertEqual('', out)
 
44
        self.assertEqual('', err)
 
45
 
37
46
    def test_init_at_repository_root(self):
38
47
        # bzr init at the root of a repository should create a branch
39
48
        # and working tree even when creation of working trees is disabled.
62
71
        
63
72
        out, err = self.run_bzr('init', 'subdir2/nothere', retcode=3)
64
73
        self.assertEqual('', out)
65
 
        self.failUnless(err.startswith(
66
 
            'bzr: ERROR: exceptions.OSError: '
67
 
            '[Errno 2] No such file or directory: '))
 
74
        self.assertContainsRe(err,
 
75
            r'^bzr: ERROR: .*'
 
76
            '\[Errno 2\] No such file or directory')
68
77
        
69
78
        os.mkdir('subdir2')
70
79
        out, err = self.run_bzr('init', 'subdir2')
74
83
        out, err = self.run_bzr('init', 'subdir2', retcode=3)
75
84
        self.assertEqual('', out)
76
85
        self.failUnless(err.startswith('bzr: ERROR: Already a branch:'))
 
86
 
 
87
    def test_init_existing_branch(self):
 
88
        self.run_bzr('init')
 
89
        out, err = self.run_bzr('init', retcode=3)
 
90
        self.assertContainsRe(err, 'Already a branch')
 
91
        # don't suggest making a checkout, there's already a working tree
 
92
        self.assertFalse(re.search(r'checkout', err))
 
93
 
 
94
    def test_init_existing_without_workingtree(self):
 
95
        # make a repository
 
96
        self.run_bzr('init-repo', '.')
 
97
        # make a branch; by default without a working tree
 
98
        self.run_bzr('init', 'subdir')
 
99
        # fail
 
100
        out, err = self.run_bzr('init', 'subdir', retcode=3)
 
101
        # suggests using checkout
 
102
        self.assertContainsRe(err, 'ontains a branch.*but no working tree.*checkout')
 
103
 
 
104
    def test_no_defaults(self):
 
105
        """Init creates no default ignore rules."""
 
106
        self.run_bzr('init')
 
107
        self.assertFalse(os.path.exists('.bzrignore'))
 
108
 
 
109
 
 
110
class TestSFTPInit(TestCaseWithSFTPServer):
 
111
 
 
112
    def test_init(self):
 
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)
 
117
    
 
118
    def test_init_existing_branch(self):
 
119
        # when there is already a branch present, make mention
 
120
        self.make_branch('.')
 
121
 
 
122
        # rely on SFTPServer get_url() pointing at '.'
 
123
        out, err = self.run_bzr_error(['Already a branch'], 'init', self.get_url())
 
124
 
 
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))
 
128
 
 
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('.')
 
133
 
 
134
        # rely on SFTPServer get_url() pointing at '.'
 
135
        self.run_bzr_error(['Already a branch'], 'init', self.get_url())