/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: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
18
 
"""Test 'brz init'"""
 
18
"""Test 'bzr init'"""
19
19
 
20
20
import os
21
21
import re
22
22
 
23
 
from breezy import (
 
23
from bzrlib import (
24
24
    branch as _mod_branch,
25
25
    config as _mod_config,
26
26
    osutils,
27
27
    urlutils,
28
28
    )
29
 
from breezy.bzr.bzrdir import BzrDirMetaFormat1
30
 
from breezy.tests import TestSkipped
31
 
from breezy.tests import TestCaseWithTransport
32
 
from breezy.tests.test_sftp_transport import TestCaseWithSFTPServer
33
 
from breezy.workingtree import WorkingTree
 
29
from bzrlib.bzrdir import BzrDirMetaFormat1
 
30
from bzrlib.tests import TestSkipped
 
31
from bzrlib.tests import TestCaseWithTransport
 
32
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
 
33
from bzrlib.workingtree import WorkingTree
34
34
 
35
35
 
36
36
class TestInit(TestCaseWithTransport):
40
40
        self._default_label = '2a'
41
41
 
42
42
    def test_init_with_format(self):
43
 
        # Verify brz init --format constructs something plausible
 
43
        # Verify bzr init --format constructs something plausible
44
44
        t = self.get_transport()
45
45
        self.run_bzr('init --format default')
46
46
        self.assertIsDirectory('.bzr', t)
54
54
            out)
55
55
        self.assertEqual('', err)
56
56
 
57
 
    def test_init_format_bzr(self):
58
 
        """Smoke test for constructing a format with the 'bzr' alias."""
59
 
        out, err = self.run_bzr('init --format=bzr')
60
 
        self.assertEqual(
61
 
            "Created a standalone tree (format: %s)\n" % self._default_label,
62
 
            out)
63
 
        self.assertEqual('', err)
64
 
 
65
57
    def test_init_colocated(self):
66
58
        """Smoke test for constructing a colocated branch."""
67
59
        out, err = self.run_bzr('init --format=development-colo file:,branch=abranch')
68
 
        self.assertEqual("""Created a standalone tree (format: development-colo)\n""",
 
60
        self.assertEqual("""Created a lightweight checkout (format: development-colo)\n""",
69
61
            out)
70
62
        self.assertEqual('', err)
71
63
        out, err = self.run_bzr('branches')
73
65
        self.assertEqual('', err)
74
66
 
75
67
    def test_init_at_repository_root(self):
76
 
        # brz init at the root of a repository should create a branch
 
68
        # bzr init at the root of a repository should create a branch
77
69
        # and working tree even when creation of working trees is disabled.
78
70
        t = self.get_transport()
79
71
        t.mkdir('repo')
85
77
        self.assertEqual("""Created a repository tree (format: %s)
86
78
Using shared repository: %s
87
79
""" % (self._default_label, urlutils.local_path_from_url(
88
 
            repo.controldir.root_transport.external_url())), out)
 
80
            repo.bzrdir.root_transport.external_url())), out)
89
81
        cwd = osutils.getcwd()
90
82
        self.assertEndsWith(out, cwd + '/repo/\n')
91
83
        self.assertEqual('', err)
118
110
        # init an existing branch.
119
111
        out, err = self.run_bzr('init subdir2', retcode=3)
120
112
        self.assertEqual('', out)
121
 
        self.assertTrue(err.startswith('brz: ERROR: Already a branch:'))
 
113
        self.assertTrue(err.startswith('bzr: ERROR: Already a branch:'))
122
114
 
123
115
    def test_init_branch_quiet(self):
124
116
        out, err = self.run_bzr('init -q')
161
153
    def create_simple_tree(self):
162
154
        tree = self.make_branch_and_tree('tree')
163
155
        self.build_tree(['tree/a'])
164
 
        tree.add(['a'], [b'a-id'])
165
 
        tree.commit('one', rev_id=b'r1')
 
156
        tree.add(['a'], ['a-id'])
 
157
        tree.commit('one', rev_id='r1')
166
158
        return tree
167
159
 
168
160
    def test_init_create_prefix(self):
169
 
        """'brz init --create-prefix; will create leading directories."""
 
161
        """'bzr init --create-prefix; will create leading directories."""
170
162
        tree = self.create_simple_tree()
171
163
 
172
164
        self.run_bzr_error(['Parent directory of ../new/tree does not exist'],
175
167
        self.assertPathExists('new/tree/.bzr')
176
168
 
177
169
    def test_init_default_format_option(self):
178
 
        """brz init should read default format from option default_format"""
 
170
        """bzr init should read default format from option default_format"""
179
171
        g_store = _mod_config.GlobalStore()
180
172
        g_store._load_from_string('''
181
173
[DEFAULT]
186
178
        self.assertContainsRe(out, '1.9')
187
179
 
188
180
    def test_init_no_tree(self):
189
 
        """'brz init --no-tree' creates a branch with no working tree."""
 
181
        """'bzr init --no-tree' creates a branch with no working tree."""
190
182
        out, err = self.run_bzr('init --no-tree')
191
183
        self.assertStartsWith(out, 'Created a standalone branch')
192
184
 
195
187
 
196
188
    def test_init(self):
197
189
        # init on a remote url should succeed.
198
 
        out, err = self.run_bzr(['init', '--format=pack-0.92', self.get_url()])
 
190
        out, err = self.run_bzr(['init', '--pack-0.92', self.get_url()])
199
191
        self.assertEqual(out,
200
192
            """Created a standalone branch (format: pack-0.92)\n""")
201
193
        self.assertEqual('', err)
208
200
        out, err = self.run_bzr_error(['Already a branch'],
209
201
                                      ['init', self.get_url()])
210
202
 
211
 
        # make sure using 'brz checkout' is not suggested
 
203
        # make sure using 'bzr checkout' is not suggested
212
204
        # for remote locations missing a working tree
213
 
        self.assertFalse(re.search(r'use brz checkout', err))
 
205
        self.assertFalse(re.search(r'use bzr checkout', err))
214
206
 
215
207
    def test_init_existing_branch_with_workingtree(self):
216
208
        # don't distinguish between the branch having a working tree or not
221
213
        self.run_bzr_error(['Already a branch'], ['init', self.get_url()])
222
214
 
223
215
    def test_init_append_revisions_only(self):
224
 
        self.run_bzr('init --format=dirstate-tags normal_branch6')
 
216
        self.run_bzr('init --dirstate-tags normal_branch6')
225
217
        branch = _mod_branch.Branch.open('normal_branch6')
226
218
        self.assertEqual(None, branch.get_append_revisions_only())
227
 
        self.run_bzr('init --append-revisions-only --format=dirstate-tags branch6')
 
219
        self.run_bzr('init --append-revisions-only --dirstate-tags branch6')
228
220
        branch = _mod_branch.Branch.open('branch6')
229
221
        self.assertEqual(True, branch.get_append_revisions_only())
230
222
        self.run_bzr_error(['cannot be set to append-revisions-only'],
231
 
                           'init --append-revisions-only --format=knit knit')
 
223
                           'init --append-revisions-only --knit knit')
232
224
 
233
225
    def test_init_without_username(self):
234
226
        """Ensure init works if username is not set.
235
227
        """
236
 
        # brz makes user specified whoami mandatory for operations
 
228
        # bzr makes user specified whoami mandatory for operations
237
229
        # like commit as whoami is recorded. init however is not so final
238
230
        # and uses whoami only in a lock file. Without whoami the login name
239
231
        # is used. This test is to ensure that init passes even when whoami
240
232
        # is not available.
241
233
        self.overrideEnv('EMAIL', None)
242
 
        self.overrideEnv('BRZ_EMAIL', None)
 
234
        self.overrideEnv('BZR_EMAIL', None)
243
235
        out, err = self.run_bzr(['init', 'foo'])
244
236
        self.assertEqual(err, '')
245
237
        self.assertTrue(os.path.exists('foo'))