/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 breezy/tests/blackbox/test_revno.py

  • Committer: Jelmer Vernooij
  • Date: 2017-06-10 01:35:53 UTC
  • mto: (6670.4.8 move-bzr)
  • mto: This revision was merged to the branch mainline in revision 6681.
  • Revision ID: jelmer@jelmer.uk-20170610013553-560y7mn3su4pp763
Fix remaining tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007, 2009 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007, 2009, 2011, 2012, 2016 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
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
18
 
"""Black-box tests for bzr revno.
 
18
"""Black-box tests for brz revno.
19
19
"""
20
20
 
21
21
import os
22
22
 
23
 
from bzrlib import tests
 
23
from breezy import tests
 
24
from breezy.tests.matchers import ContainsNoVfsCalls
 
25
 
24
26
 
25
27
class TestRevno(tests.TestCaseWithTransport):
26
28
 
32
34
        os.mkdir('a')
33
35
        os.chdir('a')
34
36
        bzr('init')
35
 
        self.assertEquals(int(bzr('revno')), 0)
 
37
        self.assertEqual(int(bzr('revno')), 0)
36
38
 
37
 
        open('foo', 'wb').write('foo\n')
 
39
        with open('foo', 'wb') as f: f.write('foo\n')
38
40
        bzr('add foo')
39
41
        bzr('commit -m foo')
40
 
        self.assertEquals(int(bzr('revno')), 1)
 
42
        self.assertEqual(int(bzr('revno')), 1)
41
43
 
42
44
        os.mkdir('baz')
43
45
        bzr('add baz')
44
46
        bzr('commit -m baz')
45
 
        self.assertEquals(int(bzr('revno')), 2)
 
47
        self.assertEqual(int(bzr('revno')), 2)
46
48
 
47
49
        os.chdir('..')
48
 
        self.assertEquals(int(bzr('revno a')), 2)
49
 
        self.assertEquals(int(bzr('revno a/baz')), 2)
 
50
        self.assertEqual(int(bzr('revno a')), 2)
 
51
        self.assertEqual(int(bzr('revno a/baz')), 2)
50
52
 
51
53
    def test_revno_tree(self):
52
54
        # Make branch and checkout
75
77
        # Try getting it's --tree revno
76
78
        out,err = self.run_bzr('revno --tree branch', retcode=3)
77
79
        self.assertEqual('', out)
78
 
        self.assertEqual('bzr: ERROR: No WorkingTree exists for "branch".\n',
 
80
        self.assertEqual('brz: ERROR: No WorkingTree exists for "branch".\n',
79
81
            err)
80
82
 
81
83
    def test_dotted_revno_tree(self):
117
119
        out, err = self.run_bzr('revno --tree checkout_b')
118
120
        self.assertEqual('', err)
119
121
        self.assertEqual('???\n', out)
 
122
 
 
123
    def test_revno_with_revision(self):
 
124
        wt = self.make_branch_and_tree('.')
 
125
        revid1 = wt.commit('rev1')
 
126
        revid2 = wt.commit('rev2')
 
127
 
 
128
        out, err = self.run_bzr('revno -r-2 .')
 
129
        self.assertEqual('1\n', out)
 
130
 
 
131
        out, err = self.run_bzr('revno -rrevid:%s .' % revid1)
 
132
        self.assertEqual('1\n', out)
 
133
 
 
134
    def test_revno_and_tree_mutually_exclusive(self):
 
135
        wt = self.make_branch_and_tree('.')
 
136
        out, err = self.run_bzr('revno -r-2 --tree .', retcode=3)
 
137
        self.assertEqual('', out)
 
138
        self.assertEqual(
 
139
            'brz: ERROR: --tree and --revision can not be used together\n',
 
140
            err)
 
141
 
 
142
 
 
143
class TestSmartServerRevno(tests.TestCaseWithTransport):
 
144
 
 
145
    def test_simple_branch_revno(self):
 
146
        self.setup_smart_server_with_call_log()
 
147
        t = self.make_branch_and_tree('branch')
 
148
        self.build_tree_contents([('branch/foo', 'thecontents')])
 
149
        t.add("foo")
 
150
        revid = t.commit("message")
 
151
        self.reset_smart_call_log()
 
152
        out, err = self.run_bzr(['revno', self.get_url('branch')])
 
153
        # This figure represent the amount of work to perform this use case. It
 
154
        # is entirely ok to reduce this number if a test fails due to rpc_count
 
155
        # being too low. If rpc_count increases, more network roundtrips have
 
156
        # become necessary for this use case. Please do not adjust this number
 
157
        # upwards without agreement from bzr's network support maintainers.
 
158
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
 
159
        self.assertLength(1, self.hpss_connections)
 
160
        self.assertLength(6, self.hpss_calls)
 
161
 
 
162
    def test_simple_branch_revno_lookup(self):
 
163
        self.setup_smart_server_with_call_log()
 
164
        t = self.make_branch_and_tree('branch')
 
165
        self.build_tree_contents([('branch/foo', 'thecontents')])
 
166
        t.add("foo")
 
167
        revid1 = t.commit("message")
 
168
        revid2 = t.commit("message")
 
169
        self.reset_smart_call_log()
 
170
        out, err = self.run_bzr(['revno', '-rrevid:' + revid1,
 
171
            self.get_url('branch')])
 
172
        # This figure represent the amount of work to perform this use case. It
 
173
        # is entirely ok to reduce this number if a test fails due to rpc_count
 
174
        # being too low. If rpc_count increases, more network roundtrips have
 
175
        # become necessary for this use case. Please do not adjust this number
 
176
        # upwards without agreement from bzr's network support maintainers.
 
177
        self.assertLength(5, self.hpss_calls)
 
178
        self.assertLength(1, self.hpss_connections)
 
179
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)