/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

Merge with prepare-shelf

Show diffs side-by-side

added added

removed removed

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