~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Robert Collins
  • Date: 2009-08-25 21:09:17 UTC
  • mto: This revision was merged to the branch mainline in revision 4650.
  • Revision ID: robertc@robertcollins.net-20090825210917-dq2i8k6n4z63pneh
Support shelve and unshelve on windows - bug 305006.

Show diffs side-by-side

added added

removed removed

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