~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Aaron Bentley
  • Date: 2007-03-07 23:15:10 UTC
  • mto: (1551.19.24 Aaron's mergeable stuff)
  • mto: This revision was merged to the branch mainline in revision 2325.
  • Revision ID: abentley@panoramicfeedback.com-20070307231510-jae63zsli83db3eb
Make ChangeReporter private

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 by Canonical Ltd
2
 
 
 
1
# Copyright (C) 2006 Canonical Ltd
 
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
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
7
 
 
 
7
#
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
11
# GNU General Public License for more details.
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
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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
 
29
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
25
30
from bzrlib.workingtree import WorkingTree
26
31
 
27
32
 
70
75
        
71
76
        out, err = self.run_bzr('init', 'subdir2/nothere', retcode=3)
72
77
        self.assertEqual('', out)
73
 
        self.failUnless(err.startswith(
74
 
            'bzr: ERROR: exceptions.OSError: '
75
 
            '[Errno 2] No such file or directory: '))
 
78
        self.assertContainsRe(err,
 
79
            r'^bzr: ERROR: No such file: .*'
 
80
            '\[Err(no|or) 2\]')
76
81
        
77
82
        os.mkdir('subdir2')
78
83
        out, err = self.run_bzr('init', 'subdir2')
100
105
        # suggests using checkout
101
106
        self.assertContainsRe(err, 'ontains a branch.*but no working tree.*checkout')
102
107
 
 
108
    def test_no_defaults(self):
 
109
        """Init creates no default ignore rules."""
 
110
        self.run_bzr('init')
 
111
        self.assertFalse(os.path.exists('.bzrignore'))
 
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
 
 
123
class TestSFTPInit(TestCaseWithSFTPServer):
 
124
 
 
125
    def test_init(self):
 
126
        # init on a remote url should succeed.
 
127
        out, err = self.run_bzr('init', self.get_url())
 
128
        self.assertEqual('', out)
 
129
        self.assertEqual('', err)
 
130
    
 
131
    def test_init_existing_branch(self):
 
132
        # when there is already a branch present, make mention
 
133
        self.make_branch('.')
 
134
 
 
135
        # rely on SFTPServer get_url() pointing at '.'
 
136
        out, err = self.run_bzr_error(['Already a branch'], 'init', self.get_url())
 
137
 
 
138
        # make sure using 'bzr checkout' is not suggested
 
139
        # for remote locations missing a working tree
 
140
        self.assertFalse(re.search(r'use bzr checkout', err))
 
141
 
 
142
    def test_init_existing_branch_with_workingtree(self):
 
143
        # don't distinguish between the branch having a working tree or not
 
144
        # when the branch itself is remote.
 
145
        self.make_branch_and_tree('.')
 
146
 
 
147
        # rely on SFTPServer get_url() pointing at '.'
 
148
        self.run_bzr_error(['Already a branch'], 'init', self.get_url())
 
149
 
 
150
    def test_init_append_revisions_only(self):
 
151
        self.run_bzr('init', '--dirstate-with-subtree', 'normal_branch6')
 
152
        branch = _mod_branch.Branch.open('normal_branch6')
 
153
        self.assertEqual(False, branch._get_append_revisions_only())
 
154
        self.run_bzr('init', '--append-revisions-only',
 
155
                     '--dirstate-with-subtree', 'branch6')
 
156
        branch = _mod_branch.Branch.open('branch6')
 
157
        self.assertEqual(True, branch._get_append_revisions_only())
 
158
        self.run_bzr_error(['cannot be set to append-revisions-only'], 'init',
 
159
            '--append-revisions-only', '--knit', 'knit')