/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

  • Committer: Robert Collins
  • Date: 2008-08-20 02:07:36 UTC
  • mfrom: (3640 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3682.
  • Revision ID: robertc@robertcollins.net-20080820020736-g2xe4921zzxtymle
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 Canonical Ltd
2
2
# -*- coding: utf-8 -*-
3
 
 
 
3
#
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.
8
 
 
 
8
#
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.
13
 
 
 
13
#
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
21
21
import os
22
22
import tempfile
23
23
 
24
 
from bzrlib.tests import ChrootedTestCase
25
 
from bzrlib.osutils import getcwd
26
 
import bzrlib.urlutils as urlutils
27
 
 
28
 
 
29
 
class TestOutsideWT(ChrootedTestCase):
 
24
from bzrlib import (
 
25
    osutils,
 
26
    tests,
 
27
    urlutils,
 
28
    )
 
29
 
 
30
 
 
31
class TestOutsideWT(tests.ChrootedTestCase):
30
32
    """Test that bzr gives proper errors outside of a working tree."""
31
33
 
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))
 
37
        os.chdir(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(),),
36
41
                         err)
37
42
 
38
43
    def test_url_log(self):
39
44
        url = self.get_readonly_url() + 'subdir/'
40
 
        out, err = self.run_bzr('log', 
41
 
                                url, retcode=3)
 
45
        out, err = self.run_bzr(['log', url], retcode=3)
42
46
        self.assertEqual(u'bzr: ERROR: Not a branch:'
43
 
                         u' %s\n' % url, err)
 
47
                         u' "%s".\n' % url, err)
 
48
 
 
49
    def test_diff_outside_tree(self):
 
50
        tmp_dir = tempfile.mkdtemp()
 
51
        self.addCleanup(lambda: osutils.rmtree(tmp_dir))
 
52
        os.chdir(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,)
 
60
        # -r X..Y
 
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,),
 
64
                         err)
 
65
        # -r X
 
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,),
 
69
                         err)
 
70
        # -r X..
 
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,),
 
74
                         err)
 
75
        # no -r at all.
 
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,),
 
79
                         err)