~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Martin Pool
  • Date: 2009-01-13 03:11:04 UTC
  • mto: This revision was merged to the branch mainline in revision 3937.
  • Revision ID: mbp@sourcefrog.net-20090113031104-03my054s02i9l2pe
Bump version to 1.12 and add news template

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006, 2007 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
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
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
 
18
18
"""Test "bzr init"""
22
22
 
23
23
from bzrlib import (
24
24
    branch as _mod_branch,
25
 
    osutils,
26
 
    urlutils,
27
25
    )
28
26
from bzrlib.bzrdir import BzrDirMetaFormat1
29
27
from bzrlib.tests import TestSkipped
34
32
 
35
33
class TestInit(ExternalBase):
36
34
 
37
 
    def setUp(self):
38
 
        ExternalBase.setUp(self)
39
 
        self._default_label = '2a'
40
 
 
41
35
    def test_init_with_format(self):
42
36
        # Verify bzr init --format constructs something plausible
43
37
        t = self.get_transport()
50
44
        # --format=weave should be accepted to allow interoperation with
51
45
        # old releases when desired.
52
46
        out, err = self.run_bzr('init --format=weave')
53
 
        self.assertEqual("""Created a standalone tree (format: weave)\n""",
54
 
            out)
55
 
        self.assertEqual('', err)
56
 
 
57
 
    def test_init_format_2a(self):
58
 
        """Smoke test for constructing a format 2a repoistory."""
59
 
        out, err = self.run_bzr('init --format=2a')
60
 
        self.assertEqual("""Created a standalone tree (format: 2a)\n""",
61
 
            out)
 
47
        self.assertEqual("""Standalone tree (format: weave)
 
48
Location:
 
49
  branch root: .
 
50
""", out)
62
51
        self.assertEqual('', err)
63
52
 
64
53
    def test_init_at_repository_root(self):
71
60
        repo = newdir.create_repository(shared=True)
72
61
        repo.set_make_working_trees(False)
73
62
        out, err = self.run_bzr('init repo')
74
 
        self.assertEqual("""Created a repository tree (format: %s)
75
 
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')
 
63
        self.assertEqual(
 
64
"""Repository tree (format: pack-0.92)
 
65
Location:
 
66
  shared repository: repo
 
67
  repository branch: repo
 
68
""", out)
80
69
        self.assertEqual('', err)
81
70
        newdir.open_branch()
82
71
        newdir.open_workingtree()
83
 
 
 
72
        
84
73
    def test_init_branch(self):
85
74
        out, err = self.run_bzr('init')
86
 
        self.assertEqual("Created a standalone tree (format: %s)\n" % (
87
 
            self._default_label,), out)
 
75
        self.assertEqual(
 
76
"""Standalone tree (format: pack-0.92)
 
77
Location:
 
78
  branch root: .
 
79
""", out)
88
80
        self.assertEqual('', err)
89
81
 
90
82
        # Can it handle subdirectories of branches too ?
91
83
        out, err = self.run_bzr('init subdir1')
92
 
        self.assertEqual("Created a standalone tree (format: %s)\n" % (
93
 
            self._default_label,), out)
 
84
        self.assertEqual(
 
85
"""Standalone tree (format: pack-0.92)
 
86
Location:
 
87
  branch root: subdir1
 
88
""", out)
94
89
        self.assertEqual('', err)
95
90
        WorkingTree.open('subdir1')
96
 
 
 
91
        
97
92
        self.run_bzr_error(['Parent directory of subdir2/nothere does not exist'],
98
93
                            'init subdir2/nothere')
99
94
        out, err = self.run_bzr('init subdir2/nothere', retcode=3)
100
95
        self.assertEqual('', out)
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("""Standalone tree (format: pack-0.92)
 
100
Location:
 
101
  branch root: subdir2
 
102
""", out)
106
103
        self.assertEqual('', err)
107
104
        # init an existing branch.
108
105
        out, err = self.run_bzr('init subdir2', retcode=3)
168
165
 
169
166
    def test_init(self):
170
167
        # init on a remote url should succeed.
171
 
        out, err = self.run_bzr(['init', '--pack-0.92', self.get_url()])
172
 
        self.assertEqual(out,
173
 
            """Created a standalone branch (format: pack-0.92)\n""")
 
168
        out, err = self.run_bzr(['init', self.get_url()])
 
169
        self.assertStartsWith(out, """Standalone branch (format: pack-0.92)
 
170
Location:
 
171
  branch root: """)
174
172
        self.assertEqual('', err)
175
 
 
 
173
    
176
174
    def test_init_existing_branch(self):
177
175
        # when there is already a branch present, make mention
178
176
        self.make_branch('.')
196
194
    def test_init_append_revisions_only(self):
197
195
        self.run_bzr('init --dirstate-tags normal_branch6')
198
196
        branch = _mod_branch.Branch.open('normal_branch6')
199
 
        self.assertEqual(None, branch._get_append_revisions_only())
 
197
        self.assertEqual(False, branch._get_append_revisions_only())
200
198
        self.run_bzr('init --append-revisions-only --dirstate-tags branch6')
201
199
        branch = _mod_branch.Branch.open('branch6')
202
200
        self.assertEqual(True, branch._get_append_revisions_only())