~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: 2007-07-04 08:08:13 UTC
  • mfrom: (2572 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2587.
  • Revision ID: robertc@robertcollins.net-20070704080813-wzebx0r88fvwj5rq
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 by 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
20
20
import os
21
21
import re
22
22
 
 
23
from bzrlib import (
 
24
    branch as _mod_branch,
 
25
    )
23
26
from bzrlib.bzrdir import BzrDirMetaFormat1
 
27
from bzrlib.tests import TestSkipped
24
28
from bzrlib.tests.blackbox import ExternalBase
25
29
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
26
30
from bzrlib.workingtree import WorkingTree
31
35
    def test_init_with_format(self):
32
36
        # Verify bzr init --format constructs something plausible
33
37
        t = self.get_transport()
34
 
        self.runbzr('init --format default')
 
38
        self.run_bzr('init --format default')
35
39
        self.assertIsDirectory('.bzr', t)
36
40
        self.assertIsDirectory('.bzr/checkout', t)
37
41
        self.assertIsDirectory('.bzr/checkout/lock', t)
69
73
        self.assertEqual('', err)
70
74
        WorkingTree.open('subdir1')
71
75
        
 
76
        self.run_bzr_error(['Parent directory of subdir2/nothere does not exist'],
 
77
                            'init', 'subdir2/nothere')
72
78
        out, err = self.run_bzr('init', 'subdir2/nothere', retcode=3)
73
79
        self.assertEqual('', out)
74
 
        self.assertContainsRe(err,
75
 
            r'^bzr: ERROR: .*'
76
 
            '\[Errno 2\] No such file or directory')
77
80
        
78
81
        os.mkdir('subdir2')
79
82
        out, err = self.run_bzr('init', 'subdir2')
93
96
 
94
97
    def test_init_existing_without_workingtree(self):
95
98
        # make a repository
96
 
        self.run_bzr('init-repo', '.')
 
99
        repo = self.make_repository('.', shared=True)
 
100
        repo.set_make_working_trees(False)
97
101
        # make a branch; by default without a working tree
98
102
        self.run_bzr('init', 'subdir')
99
103
        # fail
106
110
        self.run_bzr('init')
107
111
        self.assertFalse(os.path.exists('.bzrignore'))
108
112
 
 
113
    def test_init_unicode(self):
 
114
        # Make sure getcwd can handle unicode filenames
 
115
        try:
 
116
            os.mkdir(u'mu-\xb5')
 
117
        except UnicodeError:
 
118
            raise TestSkipped("Unable to create Unicode filename")
 
119
        # try to init unicode dir
 
120
        self.run_bzr('init', u'mu-\xb5')
 
121
 
 
122
    def create_simple_tree(self):
 
123
        tree = self.make_branch_and_tree('tree')
 
124
        self.build_tree(['tree/a'])
 
125
        tree.add(['a'], ['a-id'])
 
126
        tree.commit('one', rev_id='r1')
 
127
        return tree
 
128
 
 
129
    def test_init_create_prefix(self):
 
130
        """'bzr init --create-prefix; will create leading directories."""
 
131
        tree = self.create_simple_tree()
 
132
 
 
133
        self.run_bzr_error(['Parent directory of ../new/tree does not exist'],
 
134
                            'init', '../new/tree',
 
135
                            working_dir='tree')
 
136
        self.run_bzr('init', '../new/tree', '--create-prefix',
 
137
                        working_dir='tree')
 
138
        self.failUnlessExists('new/tree/.bzr')
 
139
 
109
140
 
110
141
class TestSFTPInit(TestCaseWithSFTPServer):
111
142
 
124
155
 
125
156
        # make sure using 'bzr checkout' is not suggested
126
157
        # for remote locations missing a working tree
127
 
        self.assertFalse(re.search(r'checkout', err))
 
158
        self.assertFalse(re.search(r'use bzr checkout', err))
128
159
 
129
160
    def test_init_existing_branch_with_workingtree(self):
130
161
        # don't distinguish between the branch having a working tree or not
133
164
 
134
165
        # rely on SFTPServer get_url() pointing at '.'
135
166
        self.run_bzr_error(['Already a branch'], 'init', self.get_url())
 
167
 
 
168
    def test_init_append_revisions_only(self):
 
169
        self.run_bzr('init', '--dirstate-tags', 'normal_branch6')
 
170
        branch = _mod_branch.Branch.open('normal_branch6')
 
171
        self.assertEqual(False, branch._get_append_revisions_only())
 
172
        self.run_bzr('init', '--append-revisions-only',
 
173
                     '--dirstate-tags', 'branch6')
 
174
        branch = _mod_branch.Branch.open('branch6')
 
175
        self.assertEqual(True, branch._get_append_revisions_only())
 
176
        self.run_bzr_error(['cannot be set to append-revisions-only'], 'init',
 
177
            '--append-revisions-only', '--knit', 'knit')