~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: John Arbash Meinel
  • Date: 2010-07-13 07:44:02 UTC
  • mto: This revision was merged to the branch mainline in revision 5342.
  • Revision ID: john@arbash-meinel.com-20100713074402-wp3oh7cyx76fkvmm
Bump trunk to 2.3-dev1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007, 2009 Canonical Ltd
 
1
# Copyright (C) 2006-2010 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
22
22
 
23
23
from bzrlib import (
24
24
    branch as _mod_branch,
 
25
    osutils,
25
26
    urlutils,
26
27
    )
27
28
from bzrlib.bzrdir import BzrDirMetaFormat1
28
29
from bzrlib.tests import TestSkipped
29
 
from bzrlib.tests.blackbox import ExternalBase
 
30
from bzrlib.tests import TestCaseWithTransport
30
31
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
31
32
from bzrlib.workingtree import WorkingTree
32
33
 
33
34
 
34
 
class TestInit(ExternalBase):
 
35
class TestInit(TestCaseWithTransport):
 
36
 
 
37
    def setUp(self):
 
38
        TestCaseWithTransport.setUp(self)
 
39
        self._default_label = '2a'
35
40
 
36
41
    def test_init_with_format(self):
37
42
        # Verify bzr init --format constructs something plausible
66
71
        repo = newdir.create_repository(shared=True)
67
72
        repo.set_make_working_trees(False)
68
73
        out, err = self.run_bzr('init repo')
69
 
        self.assertEqual("""Created a repository tree (format: pack-0.92)
 
74
        self.assertEqual("""Created a repository tree (format: %s)
70
75
Using shared repository: %s
71
 
""" % urlutils.local_path_from_url(
72
 
            repo.bzrdir.root_transport.external_url()), out)
73
 
        self.assertEndsWith(out, "bzrlib.tests.blackbox.test_init.TestInit."
74
 
            "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')
75
80
        self.assertEqual('', err)
76
81
        newdir.open_branch()
77
82
        newdir.open_workingtree()
78
83
 
79
84
    def test_init_branch(self):
80
85
        out, err = self.run_bzr('init')
81
 
        self.assertEqual("""Created a standalone tree (format: pack-0.92)\n""",
82
 
            out)
 
86
        self.assertEqual("Created a standalone tree (format: %s)\n" % (
 
87
            self._default_label,), out)
83
88
        self.assertEqual('', err)
84
89
 
85
90
        # Can it handle subdirectories of branches too ?
86
91
        out, err = self.run_bzr('init subdir1')
87
 
        self.assertEqual("""Created a standalone tree (format: pack-0.92)\n""",
88
 
            out)
 
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')
91
96
 
96
101
 
97
102
        os.mkdir('subdir2')
98
103
        out, err = self.run_bzr('init subdir2')
99
 
        self.assertEqual("""Created a standalone tree (format: pack-0.92)\n""",
100
 
            out)
 
104
        self.assertEqual("Created a standalone tree (format: %s)\n" % (
 
105
            self._default_label,), out)
101
106
        self.assertEqual('', err)
102
107
        # init an existing branch.
103
108
        out, err = self.run_bzr('init subdir2', retcode=3)
163
168
 
164
169
    def test_init(self):
165
170
        # init on a remote url should succeed.
166
 
        out, err = self.run_bzr(['init', self.get_url()])
 
171
        out, err = self.run_bzr(['init', '--pack-0.92', self.get_url()])
167
172
        self.assertEqual(out,
168
173
            """Created a standalone branch (format: pack-0.92)\n""")
169
174
        self.assertEqual('', err)
191
196
    def test_init_append_revisions_only(self):
192
197
        self.run_bzr('init --dirstate-tags normal_branch6')
193
198
        branch = _mod_branch.Branch.open('normal_branch6')
194
 
        self.assertEqual(False, branch._get_append_revisions_only())
 
199
        self.assertEqual(None, branch._get_append_revisions_only())
195
200
        self.run_bzr('init --append-revisions-only --dirstate-tags branch6')
196
201
        branch = _mod_branch.Branch.open('branch6')
197
202
        self.assertEqual(True, branch._get_append_revisions_only())
198
203
        self.run_bzr_error(['cannot be set to append-revisions-only'],
199
204
                           'init --append-revisions-only --knit knit')
 
205
 
 
206
    def test_init_without_username(self):
 
207
        """Ensure init works if username is not set.
 
208
        """
 
209
        # bzr makes user specified whoami mandatory for operations
 
210
        # like commit as whoami is recorded. init however is not so final
 
211
        # and uses whoami only in a lock file. Without whoami the login name
 
212
        # is used. This test is to ensure that init passes even when whoami
 
213
        # is not available.
 
214
        osutils.set_or_unset_env('EMAIL', None)
 
215
        osutils.set_or_unset_env('BZR_EMAIL', None)
 
216
        out, err = self.run_bzr(['init', 'foo'])
 
217
        self.assertEqual(err, '')
 
218
        self.assertTrue(os.path.exists('foo'))