~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_annotate.py

  • Committer: Alexander Belchenko
  • Date: 2008-02-07 07:53:19 UTC
  • mto: This revision was merged to the branch mainline in revision 3231.
  • Revision ID: bialix@ukr.net-20080207075319-d9jj7as8i5ztiff7
some cleanup in package_mf.py; mention about load_from_zip() deprecation in NEWS.

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
 
105
107
""".splitlines(True)
106
108
 
107
109
 
108
 
# For the 'duplicate' series, both sides introduce the same change, which then
109
 
# gets merged around. The last-modified should properly reflect this.
110
 
# We always change the fourth line so that the file is properly tracked as
111
 
# being modified in each revision. In reality, this probably would happen over
112
 
# many revisions, and it would be a different line that changes.
113
 
# BASE
114
 
#  |\
115
 
#  A B  # line should be annotated as new for A and B
116
 
#  |\|
117
 
#  C D  # line should 'converge' and say A
118
 
#  |/
119
 
#  E    # D should supersede A and stay as D (not become E because C references
120
 
#         A)
121
 
duplicate_base = annotation("""\
122
 
rev-base first
123
 
rev-base second
124
 
rev-base third
125
 
rev-base fourth-base
126
 
""")
127
 
 
128
 
duplicate_A = annotation("""\
129
 
rev-base first
130
 
rev-A alt-second
131
 
rev-base third
132
 
rev-A fourth-A
133
 
""")
134
 
 
135
 
duplicate_B = annotation("""\
136
 
rev-base first
137
 
rev-B alt-second
138
 
rev-base third
139
 
rev-B fourth-B
140
 
""")
141
 
 
142
 
duplicate_C = annotation("""\
143
 
rev-base first
144
 
rev-A alt-second
145
 
rev-base third
146
 
rev-C fourth-C
147
 
""")
148
 
 
149
 
duplicate_D = annotation("""\
150
 
rev-base first
151
 
rev-A alt-second
152
 
rev-base third
153
 
rev-D fourth-D
154
 
""")
155
 
 
156
 
duplicate_E = annotation("""\
157
 
rev-base first
158
 
rev-A alt-second
159
 
rev-base third
160
 
rev-E fourth-E
161
 
""")
162
 
 
163
 
 
164
110
class TestAnnotate(tests.TestCaseWithTransport):
165
111
 
166
112
    def create_merged_trees(self):
174
120
         |
175
121
        rev-3
176
122
        """
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
 
123
 
 
124
        tree1 = self.make_branch_and_tree('tree1')
 
125
        self.build_tree_contents([('tree1/a', 'first\n')])
 
126
        tree1.add(['a'], ['a-id'])
 
127
        tree1.commit('a', rev_id='rev-1',
 
128
                     committer="joe@foo.com",
 
129
                     timestamp=1166046000.00, timezone=0)
 
130
 
 
131
        tree2 = tree1.bzrdir.clone('tree2').open_workingtree()
 
132
 
 
133
        self.build_tree_contents([('tree1/a', 'first\nsecond\n')])
 
134
        tree1.commit('b', rev_id='rev-2',
 
135
                     committer='joe@foo.com',
 
136
                     timestamp=1166046001.00, timezone=0)
 
137
 
 
138
        self.build_tree_contents([('tree2/a', 'first\nthird\n')])
 
139
        tree2.commit('c', rev_id='rev-1_1_1',
 
140
                     committer="barry@foo.com",
 
141
                     timestamp=1166046002.00, timezone=0)
 
142
 
 
143
        num_conflicts = tree1.merge_from_branch(tree2.branch)
 
144
        self.assertEqual(1, num_conflicts)
 
145
 
 
146
        self.build_tree_contents([('tree1/a',
 
147
                                 'first\nsecond\nthird\n')])
 
148
        tree1.set_conflicts(conflicts.ConflictList())
 
149
        tree1.commit('merge 2', rev_id='rev-3',
 
150
                     committer='sal@foo.com',
 
151
                     timestamp=1166046003.00, timezone=0)
 
152
        tree1.lock_read()
 
153
        self.addCleanup(tree1.unlock)
 
154
        return tree1, tree2
194
155
 
195
156
    def create_deeply_merged_trees(self):
196
157
        """Create some trees with a more complex merge history.
215
176
         |
216
177
        rev-6
217
178
        """
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
237
 
 
238
 
    def create_duplicate_lines_tree(self):
239
 
        builder = self.make_branch_builder('branch')
240
 
        builder.start_series()
241
 
        self.addCleanup(builder.finish_series)
242
 
        base_text = ''.join(l for r, l in duplicate_base)
243
 
        a_text = ''.join(l for r, l in duplicate_A)
244
 
        b_text = ''.join(l for r, l in duplicate_B)
245
 
        c_text = ''.join(l for r, l in duplicate_C)
246
 
        d_text = ''.join(l for r, l in duplicate_D)
247
 
        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):
265
 
        if actual != expected:
266
 
            # Create an easier to understand diff when the lines don't actually
267
 
            # match
268
 
            self.assertEqualDiff(''.join('\t'.join(l) for l in expected),
269
 
                                 ''.join('\t'.join(l) for l in actual))
270
 
 
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
 
    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
288
 
        repo.lock_read()
289
 
        self.addCleanup(repo.unlock)
290
 
        self.assertRepoAnnotate(duplicate_base, repo, 'file-id', 'rev-base')
291
 
        self.assertRepoAnnotate(duplicate_A, repo, 'file-id', 'rev-A')
292
 
        self.assertRepoAnnotate(duplicate_B, repo, 'file-id', 'rev-B')
293
 
        self.assertRepoAnnotate(duplicate_C, repo, 'file-id', 'rev-C')
294
 
        self.assertRepoAnnotate(duplicate_D, repo, 'file-id', 'rev-D')
295
 
        self.assertRepoAnnotate(duplicate_E, repo, 'file-id', 'rev-E')
 
179
        tree1, tree2 = self.create_merged_trees()
 
180
        tree1.unlock()
 
181
 
 
182
        tree3 = tree2.bzrdir.clone('tree3').open_workingtree()
 
183
 
 
184
        tree2.commit('noop', rev_id='rev-1_1_2')
 
185
        self.assertEqual(0, tree1.merge_from_branch(tree2.branch))
 
186
        tree1.commit('noop merge', rev_id='rev-4')
 
187
 
 
188
        self.build_tree_contents([('tree3/a', 'first\nthird\nfourth\n')])
 
189
        tree3.commit('four', rev_id='rev-1_2_1',
 
190
                     committer='jerry@foo.com',
 
191
                     timestamp=1166046003.00, timezone=0)
 
192
 
 
193
        tree4 = tree3.bzrdir.clone('tree4').open_workingtree()
 
194
 
 
195
        tree3.commit('noop', rev_id='rev-1_2_2',
 
196
                     committer='jerry@foo.com',
 
197
                     timestamp=1166046004.00, timezone=0)
 
198
        self.assertEqual(0, tree1.merge_from_branch(tree3.branch))
 
199
        tree1.commit('merge four', rev_id='rev-5')
 
200
 
 
201
        self.build_tree_contents([('tree4/a',
 
202
                                   'first\nthird\nfourth\nfifth\nsixth\n')])
 
203
        tree4.commit('five and six', rev_id='rev-1_3_1',
 
204
                     committer='george@foo.com',
 
205
                     timestamp=1166046005.00, timezone=0)
 
206
        self.assertEqual(0, tree1.merge_from_branch(tree4.branch))
 
207
        tree1.commit('merge five and six', rev_id='rev-6')
 
208
        tree1.lock_read()
 
209
        return tree1
296
210
 
297
211
    def test_annotate_shows_dotted_revnos(self):
298
 
        builder = self.create_merged_trees()
 
212
        tree1, tree2 = self.create_merged_trees()
299
213
 
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')
 
214
        sio = StringIO()
 
215
        annotate.annotate_file(tree1.branch, 'rev-3', 'a-id',
 
216
                               to_file=sio)
 
217
        self.assertEqualDiff('1     joe@foo | first\n'
 
218
                             '2     joe@foo | second\n'
 
219
                             '1.1.1 barry@f | third\n',
 
220
                             sio.getvalue())
304
221
 
305
222
    def test_annotate_limits_dotted_revnos(self):
306
223
        """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)
 
224
        tree1 = self.create_deeply_merged_trees()
 
225
 
 
226
        sio = StringIO()
 
227
        annotate.annotate_file(tree1.branch, 'rev-6', 'a-id',
 
228
                               to_file=sio, verbose=False, full=False)
 
229
        self.assertEqualDiff('1     joe@foo | first\n'
 
230
                             '2     joe@foo | second\n'
 
231
                             '1.1.1 barry@f | third\n'
 
232
                             '1.2.1 jerry@f | fourth\n'
 
233
                             '1.3.1 george@ | fifth\n'
 
234
                             '              | sixth\n',
 
235
                             sio.getvalue())
 
236
 
 
237
        sio = StringIO()
 
238
        annotate.annotate_file(tree1.branch, 'rev-6', 'a-id',
 
239
                               to_file=sio, verbose=False, full=True)
 
240
        self.assertEqualDiff('1     joe@foo | first\n'
 
241
                             '2     joe@foo | second\n'
 
242
                             '1.1.1 barry@f | third\n'
 
243
                             '1.2.1 jerry@f | fourth\n'
 
244
                             '1.3.1 george@ | fifth\n'
 
245
                             '1.3.1 george@ | sixth\n',
 
246
                             sio.getvalue())
326
247
 
327
248
        # 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)
 
249
        sio = StringIO()
 
250
        annotate.annotate_file(tree1.branch, 'rev-6', 'a-id',
 
251
                               to_file=sio, verbose=True, full=False)
 
252
        self.assertEqualDiff('1     joe@foo.com    20061213 | first\n'
 
253
                             '2     joe@foo.com    20061213 | second\n'
 
254
                             '1.1.1 barry@foo.com  20061213 | third\n'
 
255
                             '1.2.1 jerry@foo.com  20061213 | fourth\n'
 
256
                             '1.3.1 george@foo.com 20061213 | fifth\n'
 
257
                             '                              | sixth\n',
 
258
                             sio.getvalue())
336
259
 
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)
 
260
        sio = StringIO()
 
261
        annotate.annotate_file(tree1.branch, 'rev-6', 'a-id',
 
262
                               to_file=sio, verbose=True, full=True)
 
263
        self.assertEqualDiff('1     joe@foo.com    20061213 | first\n'
 
264
                             '2     joe@foo.com    20061213 | second\n'
 
265
                             '1.1.1 barry@foo.com  20061213 | third\n'
 
266
                             '1.2.1 jerry@foo.com  20061213 | fourth\n'
 
267
                             '1.3.1 george@foo.com 20061213 | fifth\n'
 
268
                             '1.3.1 george@foo.com 20061213 | sixth\n',
 
269
                             sio.getvalue())
345
270
 
346
271
    def test_annotate_uses_branch_context(self):
347
272
        """Dotted revnos should use the Branch context.
349
274
        When annotating a non-mainline revision, the annotation should still
350
275
        use dotted revnos from the mainline.
351
276
        """
352
 
        builder = self.create_deeply_merged_trees()
 
277
        tree1 = self.create_deeply_merged_trees()
353
278
 
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)
 
279
        sio = StringIO()
 
280
        annotate.annotate_file(tree1.branch, 'rev-1_3_1', 'a-id',
 
281
                               to_file=sio, verbose=False, full=False)
 
282
        self.assertEqualDiff('1     joe@foo | first\n'
 
283
                             '1.1.1 barry@f | third\n'
 
284
                             '1.2.1 jerry@f | fourth\n'
 
285
                             '1.3.1 george@ | fifth\n'
 
286
                             '              | sixth\n',
 
287
                             sio.getvalue())
361
288
 
362
289
    def test_annotate_show_ids(self):
363
 
        builder = self.create_deeply_merged_trees()
 
290
        tree1 = self.create_deeply_merged_trees()
 
291
 
 
292
        sio = StringIO()
 
293
        annotate.annotate_file(tree1.branch, 'rev-6', 'a-id',
 
294
                               to_file=sio, show_ids=True, full=False)
364
295
 
365
296
        # 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)
 
297
        self.assertEqualDiff('    rev-1 | first\n'
 
298
                             '    rev-2 | second\n'
 
299
                             'rev-1_1_1 | third\n'
 
300
                             'rev-1_2_1 | fourth\n'
 
301
                             'rev-1_3_1 | fifth\n'
 
302
                             '          | sixth\n',
 
303
                             sio.getvalue())
 
304
 
 
305
        sio = StringIO()
 
306
        annotate.annotate_file(tree1.branch, 'rev-6', 'a-id',
 
307
                               to_file=sio, show_ids=True, full=True)
 
308
 
 
309
        self.assertEqualDiff('    rev-1 | first\n'
 
310
                             '    rev-2 | second\n'
 
311
                             'rev-1_1_1 | third\n'
 
312
                             'rev-1_2_1 | fourth\n'
 
313
                             'rev-1_3_1 | fifth\n'
 
314
                             'rev-1_3_1 | sixth\n',
 
315
                             sio.getvalue())
383
316
 
384
317
    def test_annotate_unicode_author(self):
385
318
        tree1 = self.make_branch_and_tree('tree1')
398
331
 
399
332
        tree1.lock_read()
400
333
        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
334
        # this passes if no exception is raised
406
335
        to_file = StringIO()
407
 
        annotate.annotate_file_tree(revtree_1, 'a-id',
408
 
            to_file=to_file, branch=tree1.branch)
 
336
        annotate.annotate_file(tree1.branch, 'rev-1', 'a-id', to_file=to_file)
409
337
 
410
338
        sio = StringIO()
411
339
        to_file = codecs.getwriter('ascii')(sio)
412
340
        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)
 
341
        annotate.annotate_file(tree1.branch, 'rev-2', 'b-id', to_file=to_file)
415
342
        self.assertEqualDiff('2   p?rez   | bye\n', sio.getvalue())
416
343
 
417
344
        # test now with to_file.encoding = None
418
345
        to_file = tests.StringIOWrapper()
419
346
        to_file.encoding = None
420
 
        annotate.annotate_file_tree(revtree_2, 'b-id',
421
 
            to_file=to_file, branch=tree1.branch)
 
347
        annotate.annotate_file(tree1.branch, 'rev-2', 'b-id', to_file=to_file)
422
348
        self.assertContainsRe('2   p.rez   | bye\n', to_file.getvalue())
423
349
 
424
350
        # and when it does not exist
425
351
        to_file = StringIO()
426
 
        annotate.annotate_file_tree(revtree_2, 'b-id',
427
 
            to_file=to_file, branch=tree1.branch)
 
352
        annotate.annotate_file(tree1.branch, 'rev-2', 'b-id', to_file=to_file)
428
353
        self.assertContainsRe('2   p.rez   | bye\n', to_file.getvalue())
429
354
 
430
355
    def test_annotate_author_or_committer(self):
440
365
        tree1.add(['b'], ['b-id'])
441
366
        tree1.commit('b', rev_id='rev-2',
442
367
                     committer='Committer <committer@example.com>',
443
 
                     authors=['Author <author@example.com>'],
 
368
                     author='Author <author@example.com>',
444
369
                     timestamp=1166046000.00, timezone=0)
445
370
 
446
371
        tree1.lock_read()
447
372
        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')
 
373
        to_file = StringIO()
 
374
        annotate.annotate_file(tree1.branch, 'rev-1', 'a-id', to_file=to_file)
 
375
        self.assertEqual('1   committ | hello\n', to_file.getvalue())
 
376
 
 
377
        to_file = StringIO()
 
378
        annotate.annotate_file(tree1.branch, 'rev-2', 'b-id', to_file=to_file)
 
379
        self.assertEqual('2   author@ | bye\n', to_file.getvalue())
455
380
 
456
381
 
457
382
class TestReannotate(tests.TestCase):
467
392
    def test_reannotate(self):
468
393
        self.annotateEqual(parent_1, [parent_1], new_1, 'blahblah')
469
394
        self.annotateEqual(expected_2_1, [parent_2], new_1, 'blahblah')
470
 
        self.annotateEqual(expected_1_2_2, [parent_1, parent_2], new_2,
 
395
        self.annotateEqual(expected_1_2_2, [parent_1, parent_2], new_2, 
471
396
                           'blahblah')
472
397
 
473
398
    def test_reannotate_no_parents(self):