~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_annotate.py

  • Committer: John Arbash Meinel
  • Date: 2009-06-19 21:25:51 UTC
  • mto: This revision was merged to the branch mainline in revision 4522.
  • Revision ID: john@arbash-meinel.com-20090619212551-4j7929u7kmngz3ls
update BranchBuilder to support 'committer'
Update test_annotate to use BranchBuilder rather than lots of trees and tree.commit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
176
176
         |
177
177
        rev-3
178
178
        """
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
 
179
        builder = self.make_branch_builder('branch')
 
180
        builder.start_series()
 
181
        self.addCleanup(builder.finish_series)
 
182
        builder.build_snapshot('rev-1', None, [
 
183
            ('add', ('', 'root-id', 'directory', None)),
 
184
            ('add', ('a', 'a-id', 'file', 'first\n')),
 
185
            ], timestamp=1166046000.00, committer="joe@foo.com")
 
186
        builder.build_snapshot('rev-2', ['rev-1'], [
 
187
            ('modify', ('a-id', 'first\nsecond\n')),
 
188
            ], timestamp=1166046001.00, committer="joe@foo.com")
 
189
        builder.build_snapshot('rev-1_1_1', ['rev-1'], [
 
190
            ('modify', ('a-id', 'first\nthird\n')),
 
191
            ], timestamp=1166046002.00, committer="barry@foo.com")
 
192
        builder.build_snapshot('rev-3', ['rev-2', 'rev-1_1_1'], [
 
193
            ('modify', ('a-id', 'first\nsecond\nthird\n')),
 
194
            ], timestamp=1166046003.00, committer="sal@foo.com")
 
195
        return builder
211
196
 
212
197
    def create_deeply_merged_trees(self):
213
198
        """Create some trees with a more complex merge history.
232
217
         |
233
218
        rev-6
234
219
        """
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
 
220
        builder = self.create_merged_trees()
 
221
        builder.build_snapshot('rev-1_1_2', ['rev-1_1_1'], [])
 
222
        builder.build_snapshot('rev-4', ['rev-3', 'rev-1_1_2'], [])
 
223
        builder.build_snapshot('rev-1_2_1', ['rev-1_1_1'], [
 
224
            ('modify', ('a-id', 'first\nthird\nfourth\n')),
 
225
            ], timestamp=1166046003.00, committer="jerry@foo.com")
 
226
        builder.build_snapshot('rev-1_2_2', ['rev-1_2_1'], [],
 
227
            timestamp=1166046004.00, committer="jerry@foo.com")
 
228
        builder.build_snapshot('rev-5', ['rev-4', 'rev-1_2_2'], [
 
229
            ('modify', ('a-id', 'first\nsecond\nthird\nfourth\n')),
 
230
            ], timestamp=1166046004.00, committer="jerry@foo.com")
 
231
        builder.build_snapshot('rev-1_3_1', ['rev-1_2_1'], [
 
232
            ('modify', ('a-id', 'first\nthird\nfourth\nfifth\nsixth\n')),
 
233
            ], timestamp=1166046005.00, committer="george@foo.com")
 
234
        builder.build_snapshot('rev-6', ['rev-5', 'rev-1_3_1'], [
 
235
            ('modify', ('a-id',
 
236
                        'first\nsecond\nthird\nfourth\nfifth\nsixth\n')),
 
237
            ])
 
238
        return builder
266
239
 
267
240
    def create_duplicate_lines_tree(self):
268
241
        tree1 = self.make_branch_and_tree('tree1')
319
292
        self.assertRepoAnnotate(duplicate_E, repo, 'file-id', 'rev-E')
320
293
 
321
294
    def test_annotate_shows_dotted_revnos(self):
322
 
        tree1, tree2 = self.create_merged_trees()
 
295
        builder = self.create_merged_trees()
323
296
 
324
297
        sio = StringIO()
325
 
        annotate.annotate_file(tree1.branch, 'rev-3', 'a-id',
 
298
        annotate.annotate_file(builder.get_branch(), 'rev-3', 'a-id',
326
299
                               to_file=sio)
327
300
        self.assertEqualDiff('1     joe@foo | first\n'
328
301
                             '2     joe@foo | second\n'
331
304
 
332
305
    def test_annotate_limits_dotted_revnos(self):
333
306
        """Annotate should limit dotted revnos to a depth of 12"""
334
 
        tree1 = self.create_deeply_merged_trees()
 
307
        builder = self.create_deeply_merged_trees()
335
308
 
336
309
        sio = StringIO()
337
 
        annotate.annotate_file(tree1.branch, 'rev-6', 'a-id',
 
310
        annotate.annotate_file(builder.get_branch(), 'rev-6', 'a-id',
338
311
                               to_file=sio, verbose=False, full=False)
339
312
        self.assertEqualDiff('1     joe@foo | first\n'
340
313
                             '2     joe@foo | second\n'
345
318
                             sio.getvalue())
346
319
 
347
320
        sio = StringIO()
348
 
        annotate.annotate_file(tree1.branch, 'rev-6', 'a-id',
 
321
        annotate.annotate_file(builder.get_branch(), 'rev-6', 'a-id',
349
322
                               to_file=sio, verbose=False, full=True)
350
323
        self.assertEqualDiff('1     joe@foo | first\n'
351
324
                             '2     joe@foo | second\n'
357
330
 
358
331
        # verbose=True shows everything, the full revno, user id, and date
359
332
        sio = StringIO()
360
 
        annotate.annotate_file(tree1.branch, 'rev-6', 'a-id',
 
333
        annotate.annotate_file(builder.get_branch(), 'rev-6', 'a-id',
361
334
                               to_file=sio, verbose=True, full=False)
362
335
        self.assertEqualDiff('1     joe@foo.com    20061213 | first\n'
363
336
                             '2     joe@foo.com    20061213 | second\n'
368
341
                             sio.getvalue())
369
342
 
370
343
        sio = StringIO()
371
 
        annotate.annotate_file(tree1.branch, 'rev-6', 'a-id',
 
344
        annotate.annotate_file(builder.get_branch(), 'rev-6', 'a-id',
372
345
                               to_file=sio, verbose=True, full=True)
373
346
        self.assertEqualDiff('1     joe@foo.com    20061213 | first\n'
374
347
                             '2     joe@foo.com    20061213 | second\n'
384
357
        When annotating a non-mainline revision, the annotation should still
385
358
        use dotted revnos from the mainline.
386
359
        """
387
 
        tree1 = self.create_deeply_merged_trees()
 
360
        builder = self.create_deeply_merged_trees()
388
361
 
389
362
        sio = StringIO()
390
 
        annotate.annotate_file(tree1.branch, 'rev-1_3_1', 'a-id',
 
363
        annotate.annotate_file(builder.get_branch(), 'rev-1_3_1', 'a-id',
391
364
                               to_file=sio, verbose=False, full=False)
392
365
        self.assertEqualDiff('1     joe@foo | first\n'
393
366
                             '1.1.1 barry@f | third\n'
397
370
                             sio.getvalue())
398
371
 
399
372
    def test_annotate_show_ids(self):
400
 
        tree1 = self.create_deeply_merged_trees()
 
373
        builder = self.create_deeply_merged_trees()
401
374
 
402
375
        sio = StringIO()
403
 
        annotate.annotate_file(tree1.branch, 'rev-6', 'a-id',
 
376
        annotate.annotate_file(builder.get_branch(), 'rev-6', 'a-id',
404
377
                               to_file=sio, show_ids=True, full=False)
405
378
 
406
379
        # It looks better with real revision ids :)
413
386
                             sio.getvalue())
414
387
 
415
388
        sio = StringIO()
416
 
        annotate.annotate_file(tree1.branch, 'rev-6', 'a-id',
 
389
        annotate.annotate_file(builder.get_branch(), 'rev-6', 'a-id',
417
390
                               to_file=sio, show_ids=True, full=True)
418
391
 
419
392
        self.assertEqualDiff('    rev-1 | first\n'