/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_aliases.py

  • Committer: Robert Collins
  • Date: 2010-05-06 23:41:35 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506234135-yivbzczw1sejxnxc
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now
expected to return an object which can be used to unlock them. This reduces
duplicate code when using cleanups. The previous 'tokens's returned by
``Branch.lock_write`` and ``Repository.lock_write`` are now attributes
on the result of the lock_write. ``repository.RepositoryWriteLockResult``
and ``branch.BranchWriteLockResult`` document this. (Robert Collins)

``log._get_info_for_log_files`` now takes an add_cleanup callable.
(Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007, 2009, 2010, 2016 Canonical Ltd
 
1
# Copyright (C) 2005, 2006 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
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
 
"""Black-box tests for brz aliases.
 
16
"""Black-box tests for bzr aliases.
17
17
"""
18
18
 
19
19
import os
20
20
 
21
 
from breezy import config
22
 
from breezy.branch import Branch
23
 
from breezy.tests import TestCaseWithTransport
24
 
from breezy.trace import mutter
25
 
 
26
 
 
27
 
class TestAliases(TestCaseWithTransport):
 
21
from bzrlib.branch import Branch
 
22
from bzrlib.tests.blackbox import ExternalBase
 
23
from bzrlib.trace import mutter
 
24
from bzrlib.config import (ensure_config_dir_exists, config_filename)
 
25
 
 
26
 
 
27
class TestAliases(ExternalBase):
28
28
 
29
29
    def test_aliases(self):
30
30
 
34
34
        def bzr_catch_error(args, **kwargs):
35
35
            return self.run_bzr(args, **kwargs)[1]
36
36
 
37
 
        conf = config.GlobalConfig.from_string(b'''[ALIASES]
38
 
c=cat
39
 
c1=cat -r 1
40
 
c2=cat -r 1 -r2
41
 
''', save=True)
 
37
 
 
38
        if os.path.isfile(config_filename()):
 
39
            # Something is wrong in environment,
 
40
            # we risk overwriting users config
 
41
            self.assert_(config_filename() + "exists, abort")
 
42
 
 
43
        ensure_config_dir_exists()
 
44
        CONFIG=("[ALIASES]\n"
 
45
                "c=cat\n"
 
46
                "c1=cat -r 1\n"
 
47
                "c2=cat -r 1 -r2\n")
 
48
 
 
49
        open(config_filename(),'wb').write(CONFIG)
42
50
 
43
51
        str1 = 'foo\n'
44
52
        str2 = 'bar\n'
48
56
        tree.add('a')
49
57
        tree.commit(message='1')
50
58
 
51
 
        self.assertEqual(bzr('c a'), str1)
 
59
        self.assertEquals(bzr('c a'), str1)
52
60
 
53
61
        self.build_tree_contents([('a', str2)])
54
62
        tree.commit(message='2')
55
63
 
56
 
        self.assertEqual(bzr('c a'), str2)
57
 
        self.assertEqual(bzr('c1 a'), str1)
58
 
        self.assertEqual(bzr('c1 --revision 2 a'), str2)
 
64
        self.assertEquals(bzr('c a'), str2)
 
65
        self.assertEquals(bzr('c1 a'), str1)
 
66
        self.assertEquals(bzr('c1 --revision 2 a'), str2)
59
67
 
60
68
        # If --no-aliases isn't working, we will not get retcode=3
61
69
        bzr('--no-aliases c a', retcode=3)
62
70
 
63
71
        # If --no-aliases breaks all of bzr, we also get retcode=3
64
72
        # So we need to catch the output as well
65
 
        self.assertEqual(bzr_catch_error('--no-aliases c a',
66
 
                                         retcode=None),
67
 
                         'brz: ERROR: unknown command "c". '
68
 
                         'Perhaps you meant "ci"\n')
 
73
        self.assertEquals(bzr_catch_error('--no-aliases c a',
 
74
                                          retcode=None),
 
75
                          'bzr: ERROR: unknown command "c"\n')
69
76
 
70
77
        bzr('c -r1 -r2', retcode=3)
71
78
        bzr('c1 -r1 -r2', retcode=3)