~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_log.py

  • Committer: Aaron Bentley
  • Date: 2006-06-23 14:28:15 UTC
  • mto: This revision was merged to the branch mainline in revision 1807.
  • Revision ID: abentley@panoramicfeedback.com-20060623142815-a48f3a00b1a14679
Apply review comments

Show diffs side-by-side

added added

removed removed

Lines of Context:
306
306
        log_contents = logfile.read()
307
307
        self.assertEqualDiff(log_contents, '1: Line-Log-Formatte... 2005-11-23 add a\n')
308
308
 
309
 
    def test_get_view_revisions(self):
310
 
        """Test the get_view_revisions method"""
 
309
    def make_tree_with_commits(self):
 
310
        """Create a tree with well-known revision ids"""
311
311
        wt = self.make_branch_and_tree('tree1')
312
312
        wt.commit('commit one', rev_id='1')
313
313
        wt.commit('commit two', rev_id='2')
314
314
        wt.commit('commit three', rev_id='3')
315
315
        mainline_revs = [None, '1', '2', '3']
316
 
        rev_nos = {'1': 1, '2': 2, '3': 3, '4b': 4}
317
 
        revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
318
 
                                            'forward'))
319
 
        self.assertEqual(revisions, [('1', 1, 0), ('2', 2, 0), ('3', 3, 0)])
320
 
        revisions2 = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
321
 
                                             'forward', no_merges=True))
322
 
        self.assertEqual(revisions, revisions2)
323
 
        revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
324
 
                                            'reverse'))
325
 
        self.assertEqual(revisions, [('3', 3, 0), ('2', 2, 0), ('1', 1, 0), ])
326
 
        revisions2 = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
327
 
                                             'reverse', no_merges=True))
328
 
        self.assertEqual(revisions, revisions2)
 
316
        rev_nos = {'1': 1, '2': 2, '3': 3}
 
317
        return mainline_revs, rev_nos, wt
 
318
 
 
319
    def make_tree_with_merges(self):
 
320
        """Create a tree with well-known revision ids and a merge"""
 
321
        mainline_revs, rev_nos, wt = self.make_tree_with_commits()
329
322
        tree2 = wt.bzrdir.sprout('tree2').open_workingtree()
330
323
        tree2.commit('four-a', rev_id='4a')
331
324
        wt.branch.fetch(tree2.branch, '4a')
332
325
        wt.add_pending_merge('4a')
333
326
        wt.commit('four-b', rev_id='4b')
334
327
        mainline_revs.append('4b')
 
328
        rev_nos['4b'] = 4
 
329
        return mainline_revs, rev_nos, wt
 
330
 
 
331
    def test_get_view_revisions_forward(self):
 
332
        """Test the get_view_revisions method"""
 
333
        mainline_revs, rev_nos, wt = self.make_tree_with_commits()
 
334
        revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
 
335
                                            'forward'))
 
336
        self.assertEqual(revisions, [('1', 1, 0), ('2', 2, 0), ('3', 3, 0)])
 
337
        revisions2 = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
 
338
                                             'forward', include_merges=False))
 
339
        self.assertEqual(revisions, revisions2)
 
340
 
 
341
    def test_get_view_revisions_reverse(self):
 
342
        """Test the get_view_revisions with reverse"""
 
343
        mainline_revs, rev_nos, wt = self.make_tree_with_commits()
 
344
        revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
 
345
                                            'reverse'))
 
346
        self.assertEqual(revisions, [('3', 3, 0), ('2', 2, 0), ('1', 1, 0), ])
 
347
        revisions2 = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
 
348
                                             'reverse', include_merges=False))
 
349
        self.assertEqual(revisions, revisions2)
 
350
 
 
351
    def test_get_view_revisions_merge(self):
 
352
        """Test get_view_revisions when there are merges"""
 
353
        mainline_revs, rev_nos, wt = self.make_tree_with_merges()
335
354
        revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
336
355
                                            'forward'))
337
356
        self.assertEqual(revisions, [('1', 1, 0), ('2', 2, 0), ('3', 3, 0),
338
357
                                     ('4a', None, 1), ('4b', 4, 0)])
339
358
        revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
340
 
                                             'forward', no_merges=True))
 
359
                                             'forward', include_merges=False))
341
360
        self.assertEqual(revisions, [('1', 1, 0), ('2', 2, 0), ('3', 3, 0),
342
361
                                     ('4b', 4, 0)])