~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_log.py

  • Committer: Ian Clatworthy
  • Date: 2009-01-19 19:09:08 UTC
  • mto: (3953.1.1 ianc-integration)
  • mto: This revision was merged to the branch mainline in revision 3954.
  • Revision ID: ian.clatworthy@canonical.com-20090119190908-nvwsm36u03sc5tah
add tests & NEWS item

Show diffs side-by-side

added added

removed removed

Lines of Context:
290
290
""",
291
291
                             sio.getvalue())
292
292
 
 
293
    def _prepare_tree_with_merges(self, with_tags=False):
 
294
        wt = self.make_branch_and_memory_tree('.')
 
295
        wt.lock_write()
 
296
        self.addCleanup(wt.unlock)
 
297
        wt.add('')
 
298
        wt.commit('rev-1', rev_id='rev-1',
 
299
                  timestamp=1132586655, timezone=36000,
 
300
                  committer='Joe Foo <joe@foo.com>')
 
301
        wt.commit('rev-merged', rev_id='rev-2a',
 
302
                  timestamp=1132586700, timezone=36000,
 
303
                  committer='Joe Foo <joe@foo.com>')
 
304
        wt.set_parent_ids(['rev-1', 'rev-2a'])
 
305
        wt.branch.set_last_revision_info(1, 'rev-1')
 
306
        wt.commit('rev-2', rev_id='rev-2b',
 
307
                  timestamp=1132586800, timezone=36000,
 
308
                  committer='Joe Foo <joe@foo.com>')
 
309
        if with_tags:
 
310
            branch = wt.branch
 
311
            branch.tags.set_tag('v0.2', 'rev-2b')
 
312
            wt.commit('rev-3', rev_id='rev-3',
 
313
                      timestamp=1132586900, timezone=36000,
 
314
                      committer='Jane Foo <jane@foo.com>')
 
315
            branch.tags.set_tag('v1.0rc1', 'rev-3')
 
316
            branch.tags.set_tag('v1.0', 'rev-3')
 
317
        return wt
 
318
 
293
319
    def test_short_log_with_merges(self):
294
 
        wt = self.make_branch_and_memory_tree('.')
295
 
        wt.lock_write()
296
 
        self.addCleanup(wt.unlock)
297
 
        wt.add('')
298
 
        wt.commit('rev-1', rev_id='rev-1',
299
 
                  timestamp=1132586655, timezone=36000,
300
 
                  committer='Joe Foo <joe@foo.com>')
301
 
        wt.commit('rev-merged', rev_id='rev-2a',
302
 
                  timestamp=1132586700, timezone=36000,
303
 
                  committer='Joe Foo <joe@foo.com>')
304
 
        wt.set_parent_ids(['rev-1', 'rev-2a'])
305
 
        wt.branch.set_last_revision_info(1, 'rev-1')
306
 
        wt.commit('rev-2', rev_id='rev-2b',
307
 
                  timestamp=1132586800, timezone=36000,
308
 
                  committer='Joe Foo <joe@foo.com>')
 
320
        wt = self._prepare_tree_with_merges()
309
321
        logfile = self.make_utf8_encoded_stringio()
310
322
        formatter = log.ShortLogFormatter(to_file=logfile)
311
323
        log.show_log(wt.branch, formatter)
319
331
""",
320
332
                             logfile.getvalue())
321
333
 
 
334
    def test_short_log_with_tags(self):
 
335
        wt = self._prepare_tree_with_merges(with_tags=True)
 
336
        logfile = self.make_utf8_encoded_stringio()
 
337
        formatter = log.ShortLogFormatter(to_file=logfile)
 
338
        log.show_log(wt.branch, formatter)
 
339
        self.assertEqualDiff("""\
 
340
    3 Jane Foo\t2005-11-22 {v1.0, v1.0rc1}
 
341
      rev-3
 
342
 
 
343
    2 Joe Foo\t2005-11-22 {v0.2} [merge]
 
344
      rev-2
 
345
 
 
346
    1 Joe Foo\t2005-11-22
 
347
      rev-1
 
348
 
 
349
""",
 
350
                             logfile.getvalue())
 
351
 
322
352
    def test_short_log_single_merge_revision(self):
323
353
        wt = self.make_branch_and_memory_tree('.')
324
354
        wt.lock_write()
701
731
""",
702
732
                             sio.getvalue())
703
733
 
 
734
    def _prepare_tree_with_merges(self, with_tags=False):
 
735
        wt = self.make_branch_and_memory_tree('.')
 
736
        wt.lock_write()
 
737
        self.addCleanup(wt.unlock)
 
738
        wt.add('')
 
739
        wt.commit('rev-1', rev_id='rev-1',
 
740
                  timestamp=1132586655, timezone=36000,
 
741
                  committer='Joe Foo <joe@foo.com>')
 
742
        wt.commit('rev-merged', rev_id='rev-2a',
 
743
                  timestamp=1132586700, timezone=36000,
 
744
                  committer='Joe Foo <joe@foo.com>')
 
745
        wt.set_parent_ids(['rev-1', 'rev-2a'])
 
746
        wt.branch.set_last_revision_info(1, 'rev-1')
 
747
        wt.commit('rev-2', rev_id='rev-2b',
 
748
                  timestamp=1132586800, timezone=36000,
 
749
                  committer='Joe Foo <joe@foo.com>')
 
750
        if with_tags:
 
751
            branch = wt.branch
 
752
            branch.tags.set_tag('v0.2', 'rev-2b')
 
753
            wt.commit('rev-3', rev_id='rev-3',
 
754
                      timestamp=1132586900, timezone=36000,
 
755
                      committer='Jane Foo <jane@foo.com>')
 
756
            branch.tags.set_tag('v1.0rc1', 'rev-3')
 
757
            branch.tags.set_tag('v1.0', 'rev-3')
 
758
        return wt
 
759
 
704
760
    def test_line_log_single_merge_revision(self):
705
 
        wt = self.make_branch_and_memory_tree('.')
706
 
        wt.lock_write()
707
 
        self.addCleanup(wt.unlock)
708
 
        wt.add('')
709
 
        wt.commit('rev-1', rev_id='rev-1',
710
 
                  timestamp=1132586655, timezone=36000,
711
 
                  committer='Joe Foo <joe@foo.com>')
712
 
        wt.commit('rev-merged', rev_id='rev-2a',
713
 
                  timestamp=1132586700, timezone=36000,
714
 
                  committer='Joe Foo <joe@foo.com>')
715
 
        wt.set_parent_ids(['rev-1', 'rev-2a'])
716
 
        wt.branch.set_last_revision_info(1, 'rev-1')
717
 
        wt.commit('rev-2', rev_id='rev-2b',
718
 
                  timestamp=1132586800, timezone=36000,
719
 
                  committer='Joe Foo <joe@foo.com>')
 
761
        wt = self._prepare_tree_with_merges()
720
762
        logfile = self.make_utf8_encoded_stringio()
721
763
        formatter = log.LineLogFormatter(to_file=logfile)
722
764
        revspec = revisionspec.RevisionSpec.from_string('1.1.1')
728
770
""",
729
771
                             logfile.getvalue())
730
772
 
 
773
    def test_line_log_with_tags(self):
 
774
        wt = self._prepare_tree_with_merges(with_tags=True)
 
775
        logfile = self.make_utf8_encoded_stringio()
 
776
        formatter = log.LineLogFormatter(to_file=logfile)
 
777
        log.show_log(wt.branch, formatter)
 
778
        self.assertEqualDiff("""\
 
779
3{v1.0, v1.0rc1}: Jane Foo 2005-11-22 rev-3
 
780
2{v0.2}: Joe Foo 2005-11-22 rev-2
 
781
1: Joe Foo 2005-11-22 rev-1
 
782
""",
 
783
                             logfile.getvalue())
731
784
 
732
785
 
733
786
class TestGetViewRevisions(tests.TestCaseWithTransport):