~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_annotate.py

  • Committer: John Arbash Meinel
  • Author(s): Mark Hammond
  • Date: 2008-09-09 17:02:21 UTC
  • mto: This revision was merged to the branch mainline in revision 3697.
  • Revision ID: john@arbash-meinel.com-20080909170221-svim3jw2mrz0amp3
An updated transparent icon for bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2009, 2011 Canonical Ltd
 
1
# Copyright (C) 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
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
"""Whitebox tests for annotate functionality."""
18
18
 
21
21
 
22
22
from bzrlib import (
23
23
    annotate,
24
 
    symbol_versioning,
 
24
    conflicts,
 
25
    errors,
25
26
    tests,
 
27
    trace,
26
28
    )
27
29
 
28
30
 
174
176
         |
175
177
        rev-3
176
178
        """
177
 
        builder = self.make_branch_builder('branch')
178
 
        builder.start_series()
179
 
        self.addCleanup(builder.finish_series)
180
 
        builder.build_snapshot('rev-1', None, [
181
 
            ('add', ('', 'root-id', 'directory', None)),
182
 
            ('add', ('a', 'a-id', 'file', 'first\n')),
183
 
            ], timestamp=1166046000.00, timezone=0, committer="joe@foo.com")
184
 
        builder.build_snapshot('rev-2', ['rev-1'], [
185
 
            ('modify', ('a-id', 'first\nsecond\n')),
186
 
            ], timestamp=1166046001.00, timezone=0, committer="joe@foo.com")
187
 
        builder.build_snapshot('rev-1_1_1', ['rev-1'], [
188
 
            ('modify', ('a-id', 'first\nthird\n')),
189
 
            ], timestamp=1166046002.00, timezone=0, committer="barry@foo.com")
190
 
        builder.build_snapshot('rev-3', ['rev-2', 'rev-1_1_1'], [
191
 
            ('modify', ('a-id', 'first\nsecond\nthird\n')),
192
 
            ], timestamp=1166046003.00, timezone=0, committer="sal@foo.com")
193
 
        return builder
 
179
 
 
180
        tree1 = self.make_branch_and_tree('tree1')
 
181
        self.build_tree_contents([('tree1/a', 'first\n')])
 
182
        tree1.add(['a'], ['a-id'])
 
183
        tree1.commit('a', rev_id='rev-1',
 
184
                     committer="joe@foo.com",
 
185
                     timestamp=1166046000.00, timezone=0)
 
186
 
 
187
        tree2 = tree1.bzrdir.sprout('tree2').open_workingtree()
 
188
 
 
189
        self.build_tree_contents([('tree1/a', 'first\nsecond\n')])
 
190
        tree1.commit('b', rev_id='rev-2',
 
191
                     committer='joe@foo.com',
 
192
                     timestamp=1166046001.00, timezone=0)
 
193
 
 
194
        self.build_tree_contents([('tree2/a', 'first\nthird\n')])
 
195
        tree2.commit('c', rev_id='rev-1_1_1',
 
196
                     committer="barry@foo.com",
 
197
                     timestamp=1166046002.00, timezone=0)
 
198
 
 
199
        num_conflicts = tree1.merge_from_branch(tree2.branch)
 
200
        self.assertEqual(1, num_conflicts)
 
201
 
 
202
        self.build_tree_contents([('tree1/a',
 
203
                                 'first\nsecond\nthird\n')])
 
204
        tree1.set_conflicts(conflicts.ConflictList())
 
205
        tree1.commit('merge 2', rev_id='rev-3',
 
206
                     committer='sal@foo.com',
 
207
                     timestamp=1166046003.00, timezone=0)
 
208
        tree1.lock_read()
 
209
        self.addCleanup(tree1.unlock)
 
210
        return tree1, tree2
194
211
 
195
212
    def create_deeply_merged_trees(self):
196
213
        """Create some trees with a more complex merge history.
215
232
         |
216
233
        rev-6
217
234
        """
218
 
        builder = self.create_merged_trees()
219
 
        builder.build_snapshot('rev-1_1_2', ['rev-1_1_1'], [])
220
 
        builder.build_snapshot('rev-4', ['rev-3', 'rev-1_1_2'], [])
221
 
        builder.build_snapshot('rev-1_2_1', ['rev-1_1_1'], [
222
 
            ('modify', ('a-id', 'first\nthird\nfourth\n')),
223
 
            ], timestamp=1166046003.00, timezone=0, committer="jerry@foo.com")
224
 
        builder.build_snapshot('rev-1_2_2', ['rev-1_2_1'], [],
225
 
            timestamp=1166046004.00, timezone=0, committer="jerry@foo.com")
226
 
        builder.build_snapshot('rev-5', ['rev-4', 'rev-1_2_2'], [
227
 
            ('modify', ('a-id', 'first\nsecond\nthird\nfourth\n')),
228
 
            ], timestamp=1166046004.00, timezone=0, committer="jerry@foo.com")
229
 
        builder.build_snapshot('rev-1_3_1', ['rev-1_2_1'], [
230
 
            ('modify', ('a-id', 'first\nthird\nfourth\nfifth\nsixth\n')),
231
 
            ], timestamp=1166046005.00, timezone=0, committer="george@foo.com")
232
 
        builder.build_snapshot('rev-6', ['rev-5', 'rev-1_3_1'], [
233
 
            ('modify', ('a-id',
234
 
                        'first\nsecond\nthird\nfourth\nfifth\nsixth\n')),
235
 
            ])
236
 
        return builder
 
235
        tree1, tree2 = self.create_merged_trees()
 
236
        tree1.unlock()
 
237
 
 
238
        tree3 = tree2.bzrdir.sprout('tree3').open_workingtree()
 
239
 
 
240
        tree2.commit('noop', rev_id='rev-1_1_2')
 
241
        self.assertEqual(0, tree1.merge_from_branch(tree2.branch))
 
242
        tree1.commit('noop merge', rev_id='rev-4')
 
243
 
 
244
        self.build_tree_contents([('tree3/a', 'first\nthird\nfourth\n')])
 
245
        tree3.commit('four', rev_id='rev-1_2_1',
 
246
                     committer='jerry@foo.com',
 
247
                     timestamp=1166046003.00, timezone=0)
 
248
 
 
249
        tree4 = tree3.bzrdir.sprout('tree4').open_workingtree()
 
250
 
 
251
        tree3.commit('noop', rev_id='rev-1_2_2',
 
252
                     committer='jerry@foo.com',
 
253
                     timestamp=1166046004.00, timezone=0)
 
254
        self.assertEqual(0, tree1.merge_from_branch(tree3.branch))
 
255
        tree1.commit('merge four', rev_id='rev-5')
 
256
 
 
257
        self.build_tree_contents([('tree4/a',
 
258
                                   'first\nthird\nfourth\nfifth\nsixth\n')])
 
259
        tree4.commit('five and six', rev_id='rev-1_3_1',
 
260
                     committer='george@foo.com',
 
261
                     timestamp=1166046005.00, timezone=0)
 
262
        self.assertEqual(0, tree1.merge_from_branch(tree4.branch))
 
263
        tree1.commit('merge five and six', rev_id='rev-6')
 
264
        tree1.lock_read()
 
265
        return tree1
237
266
 
238
267
    def create_duplicate_lines_tree(self):
239
 
        builder = self.make_branch_builder('branch')
240
 
        builder.start_series()
241
 
        self.addCleanup(builder.finish_series)
 
268
        tree1 = self.make_branch_and_tree('tree1')
242
269
        base_text = ''.join(l for r, l in duplicate_base)
243
270
        a_text = ''.join(l for r, l in duplicate_A)
244
271
        b_text = ''.join(l for r, l in duplicate_B)
245
272
        c_text = ''.join(l for r, l in duplicate_C)
246
273
        d_text = ''.join(l for r, l in duplicate_D)
247
274
        e_text = ''.join(l for r, l in duplicate_E)
248
 
        builder.build_snapshot('rev-base', None, [
249
 
            ('add', ('', 'root-id', 'directory', None)),
250
 
            ('add', ('file', 'file-id', 'file', base_text)),
251
 
            ])
252
 
        builder.build_snapshot('rev-A', ['rev-base'], [
253
 
            ('modify', ('file-id', a_text))])
254
 
        builder.build_snapshot('rev-B', ['rev-base'], [
255
 
            ('modify', ('file-id', b_text))])
256
 
        builder.build_snapshot('rev-C', ['rev-A'], [
257
 
            ('modify', ('file-id', c_text))])
258
 
        builder.build_snapshot('rev-D', ['rev-B', 'rev-A'], [
259
 
            ('modify', ('file-id', d_text))])
260
 
        builder.build_snapshot('rev-E', ['rev-C', 'rev-D'], [
261
 
            ('modify', ('file-id', e_text))])
262
 
        return builder
263
 
 
264
 
    def assertAnnotateEqualDiff(self, actual, expected):
 
275
        self.build_tree_contents([('tree1/file', base_text)])
 
276
        tree1.add(['file'], ['file-id'])
 
277
        tree1.commit('base', rev_id='rev-base')
 
278
        tree2 = tree1.bzrdir.sprout('tree2').open_workingtree()
 
279
 
 
280
        self.build_tree_contents([('tree1/file', a_text),
 
281
                                  ('tree2/file', b_text)])
 
282
        tree1.commit('A', rev_id='rev-A')
 
283
        tree2.commit('B', rev_id='rev-B')
 
284
 
 
285
        tree2.merge_from_branch(tree1.branch)
 
286
        conflicts.resolve(tree2, None) # Resolve the conflicts
 
287
        self.build_tree_contents([('tree2/file', d_text)])
 
288
        tree2.commit('D', rev_id='rev-D')
 
289
 
 
290
        self.build_tree_contents([('tree1/file', c_text)])
 
291
        tree1.commit('C', rev_id='rev-C')
 
292
 
 
293
        tree1.merge_from_branch(tree2.branch)
 
294
        conflicts.resolve(tree1, None) # Resolve the conflicts
 
295
        self.build_tree_contents([('tree1/file', e_text)])
 
296
        tree1.commit('E', rev_id='rev-E')
 
297
        return tree1
 
298
 
 
299
    def assertRepoAnnotate(self, expected, repo, file_id, revision_id):
 
300
        """Assert that the revision is properly annotated."""
 
301
        actual = list(repo.revision_tree(revision_id).annotate_iter(file_id))
265
302
        if actual != expected:
266
303
            # Create an easier to understand diff when the lines don't actually
267
304
            # match
268
305
            self.assertEqualDiff(''.join('\t'.join(l) for l in expected),
269
306
                                 ''.join('\t'.join(l) for l in actual))
270
307
 
271
 
    def assertBranchAnnotate(self, expected, branch, file_id, revision_id,
272
 
            verbose=False, full=False, show_ids=False):
273
 
        tree = branch.repository.revision_tree(revision_id)
274
 
        to_file = StringIO()
275
 
        annotate.annotate_file_tree(tree, file_id, to_file,
276
 
            verbose=verbose, full=full, show_ids=show_ids, branch=branch)
277
 
        self.assertAnnotateEqualDiff(to_file.getvalue(), expected)
278
 
 
279
 
    def assertRepoAnnotate(self, expected, repo, file_id, revision_id):
280
 
        """Assert that the revision is properly annotated."""
281
 
        actual = list(repo.revision_tree(revision_id).annotate_iter(file_id))
282
 
        self.assertAnnotateEqualDiff(actual, expected)
283
 
 
284
308
    def test_annotate_duplicate_lines(self):
285
 
        # XXX: Should this be a per_repository test?
286
 
        builder = self.create_duplicate_lines_tree()
287
 
        repo = builder.get_branch().repository
 
309
        # XXX: Should this be a repository_implementations test?
 
310
        tree1 = self.create_duplicate_lines_tree()
 
311
        repo = tree1.branch.repository
288
312
        repo.lock_read()
289
313
        self.addCleanup(repo.unlock)
290
314
        self.assertRepoAnnotate(duplicate_base, repo, 'file-id', 'rev-base')
295
319
        self.assertRepoAnnotate(duplicate_E, repo, 'file-id', 'rev-E')
296
320
 
297
321
    def test_annotate_shows_dotted_revnos(self):
298
 
        builder = self.create_merged_trees()
 
322
        tree1, tree2 = self.create_merged_trees()
299
323
 
300
 
        self.assertBranchAnnotate('1     joe@foo | first\n'
301
 
                                  '2     joe@foo | second\n'
302
 
                                  '1.1.1 barry@f | third\n',
303
 
                                  builder.get_branch(), 'a-id', 'rev-3')
 
324
        sio = StringIO()
 
325
        annotate.annotate_file(tree1.branch, 'rev-3', 'a-id',
 
326
                               to_file=sio)
 
327
        self.assertEqualDiff('1     joe@foo | first\n'
 
328
                             '2     joe@foo | second\n'
 
329
                             '1.1.1 barry@f | third\n',
 
330
                             sio.getvalue())
304
331
 
305
332
    def test_annotate_limits_dotted_revnos(self):
306
333
        """Annotate should limit dotted revnos to a depth of 12"""
307
 
        builder = self.create_deeply_merged_trees()
308
 
 
309
 
        self.assertBranchAnnotate('1     joe@foo | first\n'
310
 
                                  '2     joe@foo | second\n'
311
 
                                  '1.1.1 barry@f | third\n'
312
 
                                  '1.2.1 jerry@f | fourth\n'
313
 
                                  '1.3.1 george@ | fifth\n'
314
 
                                  '              | sixth\n',
315
 
                                  builder.get_branch(), 'a-id', 'rev-6',
316
 
                                  verbose=False, full=False)
317
 
 
318
 
        self.assertBranchAnnotate('1     joe@foo | first\n'
319
 
                                  '2     joe@foo | second\n'
320
 
                                  '1.1.1 barry@f | third\n'
321
 
                                  '1.2.1 jerry@f | fourth\n'
322
 
                                  '1.3.1 george@ | fifth\n'
323
 
                                  '1.3.1 george@ | sixth\n',
324
 
                                  builder.get_branch(), 'a-id', 'rev-6',
325
 
                                  verbose=False, full=True)
 
334
        tree1 = self.create_deeply_merged_trees()
 
335
 
 
336
        sio = StringIO()
 
337
        annotate.annotate_file(tree1.branch, 'rev-6', 'a-id',
 
338
                               to_file=sio, verbose=False, full=False)
 
339
        self.assertEqualDiff('1     joe@foo | first\n'
 
340
                             '2     joe@foo | second\n'
 
341
                             '1.1.1 barry@f | third\n'
 
342
                             '1.2.1 jerry@f | fourth\n'
 
343
                             '1.3.1 george@ | fifth\n'
 
344
                             '              | sixth\n',
 
345
                             sio.getvalue())
 
346
 
 
347
        sio = StringIO()
 
348
        annotate.annotate_file(tree1.branch, 'rev-6', 'a-id',
 
349
                               to_file=sio, verbose=False, full=True)
 
350
        self.assertEqualDiff('1     joe@foo | first\n'
 
351
                             '2     joe@foo | second\n'
 
352
                             '1.1.1 barry@f | third\n'
 
353
                             '1.2.1 jerry@f | fourth\n'
 
354
                             '1.3.1 george@ | fifth\n'
 
355
                             '1.3.1 george@ | sixth\n',
 
356
                             sio.getvalue())
326
357
 
327
358
        # verbose=True shows everything, the full revno, user id, and date
328
 
        self.assertBranchAnnotate('1     joe@foo.com    20061213 | first\n'
329
 
                                  '2     joe@foo.com    20061213 | second\n'
330
 
                                  '1.1.1 barry@foo.com  20061213 | third\n'
331
 
                                  '1.2.1 jerry@foo.com  20061213 | fourth\n'
332
 
                                  '1.3.1 george@foo.com 20061213 | fifth\n'
333
 
                                  '                              | sixth\n',
334
 
                                  builder.get_branch(), 'a-id', 'rev-6',
335
 
                                  verbose=True, full=False)
 
359
        sio = StringIO()
 
360
        annotate.annotate_file(tree1.branch, 'rev-6', 'a-id',
 
361
                               to_file=sio, verbose=True, full=False)
 
362
        self.assertEqualDiff('1     joe@foo.com    20061213 | first\n'
 
363
                             '2     joe@foo.com    20061213 | second\n'
 
364
                             '1.1.1 barry@foo.com  20061213 | third\n'
 
365
                             '1.2.1 jerry@foo.com  20061213 | fourth\n'
 
366
                             '1.3.1 george@foo.com 20061213 | fifth\n'
 
367
                             '                              | sixth\n',
 
368
                             sio.getvalue())
336
369
 
337
 
        self.assertBranchAnnotate('1     joe@foo.com    20061213 | first\n'
338
 
                                  '2     joe@foo.com    20061213 | second\n'
339
 
                                  '1.1.1 barry@foo.com  20061213 | third\n'
340
 
                                  '1.2.1 jerry@foo.com  20061213 | fourth\n'
341
 
                                  '1.3.1 george@foo.com 20061213 | fifth\n'
342
 
                                  '1.3.1 george@foo.com 20061213 | sixth\n',
343
 
                                  builder.get_branch(), 'a-id', 'rev-6',
344
 
                                  verbose=True, full=True)
 
370
        sio = StringIO()
 
371
        annotate.annotate_file(tree1.branch, 'rev-6', 'a-id',
 
372
                               to_file=sio, verbose=True, full=True)
 
373
        self.assertEqualDiff('1     joe@foo.com    20061213 | first\n'
 
374
                             '2     joe@foo.com    20061213 | second\n'
 
375
                             '1.1.1 barry@foo.com  20061213 | third\n'
 
376
                             '1.2.1 jerry@foo.com  20061213 | fourth\n'
 
377
                             '1.3.1 george@foo.com 20061213 | fifth\n'
 
378
                             '1.3.1 george@foo.com 20061213 | sixth\n',
 
379
                             sio.getvalue())
345
380
 
346
381
    def test_annotate_uses_branch_context(self):
347
382
        """Dotted revnos should use the Branch context.
349
384
        When annotating a non-mainline revision, the annotation should still
350
385
        use dotted revnos from the mainline.
351
386
        """
352
 
        builder = self.create_deeply_merged_trees()
 
387
        tree1 = self.create_deeply_merged_trees()
353
388
 
354
 
        self.assertBranchAnnotate('1     joe@foo | first\n'
355
 
                                  '1.1.1 barry@f | third\n'
356
 
                                  '1.2.1 jerry@f | fourth\n'
357
 
                                  '1.3.1 george@ | fifth\n'
358
 
                                  '              | sixth\n',
359
 
                                  builder.get_branch(), 'a-id', 'rev-1_3_1',
360
 
                                  verbose=False, full=False)
 
389
        sio = StringIO()
 
390
        annotate.annotate_file(tree1.branch, 'rev-1_3_1', 'a-id',
 
391
                               to_file=sio, verbose=False, full=False)
 
392
        self.assertEqualDiff('1     joe@foo | first\n'
 
393
                             '1.1.1 barry@f | third\n'
 
394
                             '1.2.1 jerry@f | fourth\n'
 
395
                             '1.3.1 george@ | fifth\n'
 
396
                             '              | sixth\n',
 
397
                             sio.getvalue())
361
398
 
362
399
    def test_annotate_show_ids(self):
363
 
        builder = self.create_deeply_merged_trees()
 
400
        tree1 = self.create_deeply_merged_trees()
 
401
 
 
402
        sio = StringIO()
 
403
        annotate.annotate_file(tree1.branch, 'rev-6', 'a-id',
 
404
                               to_file=sio, show_ids=True, full=False)
364
405
 
365
406
        # It looks better with real revision ids :)
366
 
        self.assertBranchAnnotate('    rev-1 | first\n'
367
 
                                  '    rev-2 | second\n'
368
 
                                  'rev-1_1_1 | third\n'
369
 
                                  'rev-1_2_1 | fourth\n'
370
 
                                  'rev-1_3_1 | fifth\n'
371
 
                                  '          | sixth\n',
372
 
                                  builder.get_branch(), 'a-id', 'rev-6',
373
 
                                  show_ids=True, full=False)
374
 
 
375
 
        self.assertBranchAnnotate('    rev-1 | first\n'
376
 
                                  '    rev-2 | second\n'
377
 
                                  'rev-1_1_1 | third\n'
378
 
                                  'rev-1_2_1 | fourth\n'
379
 
                                  'rev-1_3_1 | fifth\n'
380
 
                                  'rev-1_3_1 | sixth\n',
381
 
                                  builder.get_branch(), 'a-id', 'rev-6',
382
 
                                  show_ids=True, full=True)
 
407
        self.assertEqualDiff('    rev-1 | first\n'
 
408
                             '    rev-2 | second\n'
 
409
                             'rev-1_1_1 | third\n'
 
410
                             'rev-1_2_1 | fourth\n'
 
411
                             'rev-1_3_1 | fifth\n'
 
412
                             '          | sixth\n',
 
413
                             sio.getvalue())
 
414
 
 
415
        sio = StringIO()
 
416
        annotate.annotate_file(tree1.branch, 'rev-6', 'a-id',
 
417
                               to_file=sio, show_ids=True, full=True)
 
418
 
 
419
        self.assertEqualDiff('    rev-1 | first\n'
 
420
                             '    rev-2 | second\n'
 
421
                             'rev-1_1_1 | third\n'
 
422
                             'rev-1_2_1 | fourth\n'
 
423
                             'rev-1_3_1 | fifth\n'
 
424
                             'rev-1_3_1 | sixth\n',
 
425
                             sio.getvalue())
383
426
 
384
427
    def test_annotate_unicode_author(self):
385
428
        tree1 = self.make_branch_and_tree('tree1')
398
441
 
399
442
        tree1.lock_read()
400
443
        self.addCleanup(tree1.unlock)
401
 
 
402
 
        revtree_1 = tree1.branch.repository.revision_tree('rev-1')
403
 
        revtree_2 = tree1.branch.repository.revision_tree('rev-2')
404
 
 
405
444
        # this passes if no exception is raised
406
445
        to_file = StringIO()
407
 
        annotate.annotate_file_tree(revtree_1, 'a-id',
408
 
            to_file=to_file, branch=tree1.branch)
 
446
        annotate.annotate_file(tree1.branch, 'rev-1', 'a-id', to_file=to_file)
409
447
 
410
448
        sio = StringIO()
411
449
        to_file = codecs.getwriter('ascii')(sio)
412
450
        to_file.encoding = 'ascii' # codecs does not set it
413
 
        annotate.annotate_file_tree(revtree_2, 'b-id',
414
 
            to_file=to_file, branch=tree1.branch)
 
451
        annotate.annotate_file(tree1.branch, 'rev-2', 'b-id', to_file=to_file)
415
452
        self.assertEqualDiff('2   p?rez   | bye\n', sio.getvalue())
416
453
 
417
454
        # test now with to_file.encoding = None
418
455
        to_file = tests.StringIOWrapper()
419
456
        to_file.encoding = None
420
 
        annotate.annotate_file_tree(revtree_2, 'b-id',
421
 
            to_file=to_file, branch=tree1.branch)
 
457
        annotate.annotate_file(tree1.branch, 'rev-2', 'b-id', to_file=to_file)
422
458
        self.assertContainsRe('2   p.rez   | bye\n', to_file.getvalue())
423
459
 
424
460
        # and when it does not exist
425
461
        to_file = StringIO()
426
 
        annotate.annotate_file_tree(revtree_2, 'b-id',
427
 
            to_file=to_file, branch=tree1.branch)
 
462
        annotate.annotate_file(tree1.branch, 'rev-2', 'b-id', to_file=to_file)
428
463
        self.assertContainsRe('2   p.rez   | bye\n', to_file.getvalue())
429
464
 
430
465
    def test_annotate_author_or_committer(self):
440
475
        tree1.add(['b'], ['b-id'])
441
476
        tree1.commit('b', rev_id='rev-2',
442
477
                     committer='Committer <committer@example.com>',
443
 
                     authors=['Author <author@example.com>'],
 
478
                     author='Author <author@example.com>',
444
479
                     timestamp=1166046000.00, timezone=0)
445
480
 
446
481
        tree1.lock_read()
447
482
        self.addCleanup(tree1.unlock)
448
 
 
449
 
        self.assertBranchAnnotate('1   committ | hello\n', tree1.branch,
450
 
            'a-id', 'rev-1')
451
 
 
452
 
        to_file = StringIO()
453
 
        self.assertBranchAnnotate('2   author@ | bye\n', tree1.branch,
454
 
            'b-id', 'rev-2')
 
483
        to_file = StringIO()
 
484
        annotate.annotate_file(tree1.branch, 'rev-1', 'a-id', to_file=to_file)
 
485
        self.assertEqual('1   committ | hello\n', to_file.getvalue())
 
486
 
 
487
        to_file = StringIO()
 
488
        annotate.annotate_file(tree1.branch, 'rev-2', 'b-id', to_file=to_file)
 
489
        self.assertEqual('2   author@ | bye\n', to_file.getvalue())
455
490
 
456
491
 
457
492
class TestReannotate(tests.TestCase):
467
502
    def test_reannotate(self):
468
503
        self.annotateEqual(parent_1, [parent_1], new_1, 'blahblah')
469
504
        self.annotateEqual(expected_2_1, [parent_2], new_1, 'blahblah')
470
 
        self.annotateEqual(expected_1_2_2, [parent_1, parent_2], new_2,
 
505
        self.annotateEqual(expected_1_2_2, [parent_1, parent_2], new_2, 
471
506
                           'blahblah')
472
507
 
473
508
    def test_reannotate_no_parents(self):