~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-04-09 20:23:07 UTC
  • mfrom: (4265.1.4 bbc-merge)
  • Revision ID: pqm@pqm.ubuntu.com-20090409202307-n0depb16qepoe21o
(jam) Change _fetch_uses_deltas = False for CHK repos until we can
        write a better fix.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
"""Black-box tests for bzr aliases.
17
17
"""
18
18
 
19
19
import os
20
20
 
21
21
from bzrlib.branch import Branch
22
 
from bzrlib.tests import TestCaseInTempDir
 
22
from bzrlib.tests.blackbox import ExternalBase
23
23
from bzrlib.trace import mutter
24
24
from bzrlib.config import (ensure_config_dir_exists, config_filename)
25
25
 
26
26
 
27
 
class TestAliases(TestCaseInTempDir):
 
27
class TestAliases(ExternalBase):
28
28
 
29
29
    def test_aliases(self):
30
30
 
31
 
        def bzr(*args, **kwargs):
32
 
            return self.run_bzr(*args, **kwargs)[0]
 
31
        def bzr(args, **kwargs):
 
32
            return self.run_bzr(args, **kwargs)[0]
33
33
 
34
 
        def bzr_catch_error(*args, **kwargs):
35
 
            return self.run_bzr(*args, **kwargs)[1]
 
34
        def bzr_catch_error(args, **kwargs):
 
35
            return self.run_bzr(args, **kwargs)[1]
36
36
 
37
37
 
38
38
        if os.path.isfile(config_filename()):
39
 
            # Something is wrong in environment, 
40
 
            # we risk overwriting users config 
 
39
            # Something is wrong in environment,
 
40
            # we risk overwriting users config
41
41
            self.assert_(config_filename() + "exists, abort")
42
 
        
 
42
 
43
43
        ensure_config_dir_exists()
44
44
        CONFIG=("[ALIASES]\n"
45
45
                "c=cat\n"
48
48
 
49
49
        open(config_filename(),'wb').write(CONFIG)
50
50
 
51
 
 
52
51
        str1 = 'foo\n'
53
52
        str2 = 'bar\n'
54
53
 
55
 
        bzr('init')
56
 
        open('a', 'wb').write(str1)
57
 
        bzr('add', 'a')
58
 
 
59
 
        bzr('commit', '-m', '1')
60
 
 
61
 
        self.assertEquals(bzr('c', 'a'), str1)
62
 
 
63
 
        open('a', 'wb').write(str2)
64
 
        bzr('commit', '-m', '2')
65
 
 
66
 
        self.assertEquals(bzr('c', 'a'), str2)
67
 
        self.assertEquals(bzr('c1', 'a'), str1)
68
 
        self.assertEquals(bzr('c1', '--revision', '2', 'a'), str2)
 
54
        tree = self.make_branch_and_tree('.')
 
55
        self.build_tree_contents([('a', str1)])
 
56
        tree.add('a')
 
57
        tree.commit(message='1')
 
58
 
 
59
        self.assertEquals(bzr('c a'), str1)
 
60
 
 
61
        self.build_tree_contents([('a', str2)])
 
62
        tree.commit(message='2')
 
63
 
 
64
        self.assertEquals(bzr('c a'), str2)
 
65
        self.assertEquals(bzr('c1 a'), str1)
 
66
        self.assertEquals(bzr('c1 --revision 2 a'), str2)
69
67
 
70
68
        # If --no-aliases isn't working, we will not get retcode=3
71
 
        bzr('--no-aliases', 'c', 'a', retcode=3)
 
69
        bzr('--no-aliases c a', retcode=3)
72
70
 
73
71
        # If --no-aliases breaks all of bzr, we also get retcode=3
74
72
        # So we need to catch the output as well
75
 
        self.assertEquals(bzr_catch_error('--no-aliases', 'c', 'a',
 
73
        self.assertEquals(bzr_catch_error('--no-aliases c a',
76
74
                                          retcode=None),
77
75
                          'bzr: ERROR: unknown command "c"\n')
78
76
 
79
 
        bzr('c', '-r1', '-r2', retcode=3)
80
 
        bzr('c1', '-r1', '-r2', retcode=3)
 
77
        bzr('c -r1 -r2', retcode=3)
 
78
        bzr('c1 -r1 -r2', retcode=3)
81
79
        bzr('c2', retcode=3)
82
 
        bzr('c2', '-r1', retcode=3)
 
80
        bzr('c2 -r1', retcode=3)