~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-05-11 15:04:23 UTC
  • mfrom: (5848.1.1 2.4-cython-first)
  • Revision ID: pqm@pqm.ubuntu.com-20110511150423-tpm1ablukqalkvim
(jameinel) Default to using Cython for compiling code,
 rather than Pyrex. (John A Meinel)

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
"""
25
25
 
26
26
 
27
 
from bzrlib import (
28
 
    config,
29
 
    tests,
30
 
    )
 
27
from bzrlib import tests
31
28
 
32
 
from bzrlib.tests.matchers import ContainsNoVfsCalls
 
29
from bzrlib.config import extract_email_address
33
30
from bzrlib.urlutils import joinpath
34
31
 
35
32
 
163
160
        tree.add('file')
164
161
        tree.commit('add file', committer="test@host", rev_id="rev1")
165
162
        self.build_tree_contents([(file_relpath, 'foo\nbar\ngam\n')])
 
163
        tree.branch.get_config().set_user_option('email', 'current@host2')
166
164
        return tree
167
165
 
168
166
    def test_annotate_cmd_revspec_branch(self):
178
176
 
179
177
    def test_annotate_edited_file(self):
180
178
        tree = self._setup_edited_file()
181
 
        self.overrideEnv('BZR_EMAIL', 'current@host2')
182
179
        out, err = self.run_bzr('annotate file')
183
180
        self.assertEqual(
184
181
            '1   test@ho | foo\n'
186
183
            '1   test@ho | gam\n',
187
184
            out)
188
185
 
189
 
    def test_annotate_edited_file_no_default(self):
190
 
        # Ensure that when no username is available annotate still works.
191
 
        self.overrideEnv('EMAIL', None)
192
 
        self.overrideEnv('BZR_EMAIL', None)
193
 
        # Also, make sure that it's not inferred from mailname.
194
 
        self.overrideAttr(config, '_auto_user_id',
195
 
            lambda: (None, None))
196
 
        tree = self._setup_edited_file()
197
 
        out, err = self.run_bzr('annotate file')
198
 
        self.assertEqual(
199
 
            '1   test@ho | foo\n'
200
 
            '2?  local u | bar\n'
201
 
            '1   test@ho | gam\n',
202
 
            out)
203
 
 
204
186
    def test_annotate_edited_file_show_ids(self):
205
187
        tree = self._setup_edited_file()
206
 
        self.overrideEnv('BZR_EMAIL', 'current@host2')
207
188
        out, err = self.run_bzr('annotate file --show-ids')
208
189
        self.assertEqual(
209
190
            '    rev1 | foo\n'
233
214
    def test_annotated_edited_merged_file_revnos(self):
234
215
        wt = self._create_merged_file()
235
216
        out, err = self.run_bzr(['annotate', 'file'])
236
 
        email = config.extract_email_address(
237
 
            wt.branch.get_config_stack().get('email'))
 
217
        email = extract_email_address(wt.branch.get_config().username())
238
218
        self.assertEqual(
239
219
            '3?    %-7s | local\n'
240
220
            '1     test@ho | foo\n'
309
289
        wt.commit('commit', committer='test@user')
310
290
        out, err = self.run_bzr(['annotate', '-d', 'a', 'hello.txt'])
311
291
        self.assertEqualDiff('1   test@us | my helicopter\n', out)
312
 
 
313
 
 
314
 
class TestSmartServerAnnotate(tests.TestCaseWithTransport):
315
 
 
316
 
    def test_simple_annotate(self):
317
 
        self.setup_smart_server_with_call_log()
318
 
        wt = self.make_branch_and_tree('branch')
319
 
        self.build_tree_contents([('branch/hello.txt', 'my helicopter\n')])
320
 
        wt.add(['hello.txt'])
321
 
        wt.commit('commit', committer='test@user')
322
 
        self.reset_smart_call_log()
323
 
        out, err = self.run_bzr(['annotate', "-d", self.get_url('branch'),
324
 
            "hello.txt"])
325
 
        # This figure represent the amount of work to perform this use case. It
326
 
        # is entirely ok to reduce this number if a test fails due to rpc_count
327
 
        # being too low. If rpc_count increases, more network roundtrips have
328
 
        # become necessary for this use case. Please do not adjust this number
329
 
        # upwards without agreement from bzr's network support maintainers.
330
 
        self.assertLength(16, self.hpss_calls)
331
 
        self.assertLength(1, self.hpss_connections)
332
 
        self.expectFailure("annotate accesses inventories, which require VFS access",
333
 
            self.assertThat, self.hpss_calls, ContainsNoVfsCalls)