~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: 2009-06-16 13:57:14 UTC
  • mto: This revision was merged to the branch mainline in revision 4449.
  • Revision ID: john@arbash-meinel.com-20090616135714-8o7jdtqqsfuv914z
The new code removes a get_parent_map call.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006, 2007, 2009 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,
26
25
    urlutils,
27
26
    )
28
27
from bzrlib.bzrdir import BzrDirMetaFormat1
29
28
from bzrlib.tests import TestSkipped
30
 
from bzrlib.tests import TestCaseWithTransport
 
29
from bzrlib.tests.blackbox import ExternalBase
31
30
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
32
31
from bzrlib.workingtree import WorkingTree
33
32
 
34
33
 
35
 
class TestInit(TestCaseWithTransport):
36
 
 
37
 
    def setUp(self):
38
 
        TestCaseWithTransport.setUp(self)
39
 
        self._default_label = '2a'
 
34
class TestInit(ExternalBase):
40
35
 
41
36
    def test_init_with_format(self):
42
37
        # Verify bzr init --format constructs something plausible
71
66
        repo = newdir.create_repository(shared=True)
72
67
        repo.set_make_working_trees(False)
73
68
        out, err = self.run_bzr('init repo')
74
 
        self.assertEqual("""Created a repository tree (format: %s)
 
69
        self.assertEqual("""Created a repository tree (format: pack-0.92)
75
70
Using shared repository: %s
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')
 
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")
80
75
        self.assertEqual('', err)
81
76
        newdir.open_branch()
82
77
        newdir.open_workingtree()
83
78
 
84
79
    def test_init_branch(self):
85
80
        out, err = self.run_bzr('init')
86
 
        self.assertEqual("Created a standalone tree (format: %s)\n" % (
87
 
            self._default_label,), out)
 
81
        self.assertEqual("""Created a standalone tree (format: pack-0.92)\n""",
 
82
            out)
88
83
        self.assertEqual('', err)
89
84
 
90
85
        # Can it handle subdirectories of branches too ?
91
86
        out, err = self.run_bzr('init subdir1')
92
 
        self.assertEqual("Created a standalone tree (format: %s)\n" % (
93
 
            self._default_label,), out)
 
87
        self.assertEqual("""Created a standalone tree (format: pack-0.92)\n""",
 
88
            out)
94
89
        self.assertEqual('', err)
95
90
        WorkingTree.open('subdir1')
96
91
 
101
96
 
102
97
        os.mkdir('subdir2')
103
98
        out, err = self.run_bzr('init subdir2')
104
 
        self.assertEqual("Created a standalone tree (format: %s)\n" % (
105
 
            self._default_label,), out)
 
99
        self.assertEqual("""Created a standalone tree (format: pack-0.92)\n""",
 
100
            out)
106
101
        self.assertEqual('', err)
107
102
        # init an existing branch.
108
103
        out, err = self.run_bzr('init subdir2', retcode=3)
168
163
 
169
164
    def test_init(self):
170
165
        # init on a remote url should succeed.
171
 
        out, err = self.run_bzr(['init', '--pack-0.92', self.get_url()])
 
166
        out, err = self.run_bzr(['init', self.get_url()])
172
167
        self.assertEqual(out,
173
168
            """Created a standalone branch (format: pack-0.92)\n""")
174
169
        self.assertEqual('', err)
196
191
    def test_init_append_revisions_only(self):
197
192
        self.run_bzr('init --dirstate-tags normal_branch6')
198
193
        branch = _mod_branch.Branch.open('normal_branch6')
199
 
        self.assertEqual(None, branch._get_append_revisions_only())
 
194
        self.assertEqual(False, branch._get_append_revisions_only())
200
195
        self.run_bzr('init --append-revisions-only --dirstate-tags branch6')
201
196
        branch = _mod_branch.Branch.open('branch6')
202
197
        self.assertEqual(True, branch._get_append_revisions_only())
203
198
        self.run_bzr_error(['cannot be set to append-revisions-only'],
204
199
                           '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'))