1
# Copyright (C) 2006 by Canonical Ltd
1
# Copyright (C) 2006 Canonical Ltd
2
2
# -*- coding: utf-8 -*-
4
4
# This program is free software; you can redistribute it and/or modify
5
5
# it under the terms of the GNU General Public License as published by
6
6
# the Free Software Foundation; either version 2 of the License, or
7
7
# (at your option) any later version.
9
9
# This program is distributed in the hope that it will be useful,
10
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
12
# GNU General Public License for more details.
14
14
# You should have received a copy of the GNU General Public License
15
15
# along with this program; if not, write to the Free Software
16
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24
from bzrlib.tests import ChrootedTestCase
25
from bzrlib.osutils import getcwd
26
import bzrlib.urlutils as urlutils
29
class TestOutsideWT(ChrootedTestCase):
31
class TestOutsideWT(tests.ChrootedTestCase):
30
32
"""Test that bzr gives proper errors outside of a working tree."""
32
34
def test_cwd_log(self):
33
os.chdir(tempfile.mkdtemp())
35
tmp_dir = tempfile.mkdtemp()
36
self.addCleanup(lambda: osutils.rmtree(tmp_dir))
34
38
out, err = self.run_bzr('log', retcode=3)
35
self.assertEqual(u'bzr: ERROR: Not a branch: %s/\n' % (getcwd(),),
39
self.assertEqual(u'bzr: ERROR: Not a branch: "%s/".\n'
40
% (osutils.getcwd(),),
38
43
def test_url_log(self):
39
44
url = self.get_readonly_url() + 'subdir/'
40
out, err = self.run_bzr('log',
45
out, err = self.run_bzr(['log', url], retcode=3)
42
46
self.assertEqual(u'bzr: ERROR: Not a branch:'
47
u' "%s".\n' % url, err)
49
def test_diff_outside_tree(self):
50
tmp_dir = tempfile.mkdtemp()
51
self.addCleanup(lambda: osutils.rmtree(tmp_dir))
53
self.run_bzr('init branch1')
54
self.run_bzr(['commit', '-m', 'nothing',
55
'--unchanged', 'branch1'])
56
self.run_bzr(['commit', '-m', 'nothing',
57
'--unchanged', 'branch1'])
58
this_dir = osutils.getcwd()
59
branch2 = "%s/branch2" % (this_dir,)
61
out, err = self.run_bzr('diff -r revno:2:branch2..revno:1', retcode=3)
62
self.assertEquals('', out)
63
self.assertEqual(u'bzr: ERROR: Not a branch: "%s/".\n' % (branch2,),
66
out, err = self.run_bzr('diff -r revno:2:branch2', retcode=3)
67
self.assertEquals('', out)
68
self.assertEqual(u'bzr: ERROR: Not a branch: "%s/".\n' % (branch2,),
71
out, err = self.run_bzr('diff -r revno:2:branch2..', retcode=3)
72
self.assertEquals('', out)
73
self.assertEqual(u'bzr: ERROR: Not a branch: "%s/".\n' % (branch2,),
76
out, err = self.run_bzr('diff', retcode=3)
77
self.assertEquals('', out)
78
self.assertEqual(u'bzr: ERROR: Not a branch: "%s/".\n' % (this_dir,),