~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_log.py

show tags in log --short/--line

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)
357
369
""",
358
370
                             logfile.getvalue())
359
371
 
 
372
    def test_short_log_with_tags(self):
 
373
        wt = self._prepare_tree_with_merges(with_tags=True)
 
374
        logfile = self.make_utf8_encoded_stringio()
 
375
        formatter = log.ShortLogFormatter(to_file=logfile)
 
376
        log.show_log(wt.branch, formatter)
 
377
        self.assertEqualDiff("""\
 
378
    3 Jane Foo\t2005-11-22 {v1.0, v1.0rc1}
 
379
      rev-3
 
380
 
 
381
    2 Joe Foo\t2005-11-22 {v0.2} [merge]
 
382
      rev-2
 
383
 
 
384
    1 Joe Foo\t2005-11-22
 
385
      rev-1
 
386
 
 
387
""",
 
388
                             logfile.getvalue())
 
389
 
360
390
    def test_short_log_single_merge_revision(self):
361
391
        wt = self.make_branch_and_memory_tree('.')
362
392
        wt.lock_write()
739
769
""",
740
770
                             sio.getvalue())
741
771
 
 
772
    def _prepare_tree_with_merges(self, with_tags=False):
 
773
        wt = self.make_branch_and_memory_tree('.')
 
774
        wt.lock_write()
 
775
        self.addCleanup(wt.unlock)
 
776
        wt.add('')
 
777
        wt.commit('rev-1', rev_id='rev-1',
 
778
                  timestamp=1132586655, timezone=36000,
 
779
                  committer='Joe Foo <joe@foo.com>')
 
780
        wt.commit('rev-merged', rev_id='rev-2a',
 
781
                  timestamp=1132586700, timezone=36000,
 
782
                  committer='Joe Foo <joe@foo.com>')
 
783
        wt.set_parent_ids(['rev-1', 'rev-2a'])
 
784
        wt.branch.set_last_revision_info(1, 'rev-1')
 
785
        wt.commit('rev-2', rev_id='rev-2b',
 
786
                  timestamp=1132586800, timezone=36000,
 
787
                  committer='Joe Foo <joe@foo.com>')
 
788
        if with_tags:
 
789
            branch = wt.branch
 
790
            branch.tags.set_tag('v0.2', 'rev-2b')
 
791
            wt.commit('rev-3', rev_id='rev-3',
 
792
                      timestamp=1132586900, timezone=36000,
 
793
                      committer='Jane Foo <jane@foo.com>')
 
794
            branch.tags.set_tag('v1.0rc1', 'rev-3')
 
795
            branch.tags.set_tag('v1.0', 'rev-3')
 
796
        return wt
 
797
 
742
798
    def test_line_log_single_merge_revision(self):
743
 
        wt = self.make_branch_and_memory_tree('.')
744
 
        wt.lock_write()
745
 
        self.addCleanup(wt.unlock)
746
 
        wt.add('')
747
 
        wt.commit('rev-1', rev_id='rev-1',
748
 
                  timestamp=1132586655, timezone=36000,
749
 
                  committer='Joe Foo <joe@foo.com>')
750
 
        wt.commit('rev-merged', rev_id='rev-2a',
751
 
                  timestamp=1132586700, timezone=36000,
752
 
                  committer='Joe Foo <joe@foo.com>')
753
 
        wt.set_parent_ids(['rev-1', 'rev-2a'])
754
 
        wt.branch.set_last_revision_info(1, 'rev-1')
755
 
        wt.commit('rev-2', rev_id='rev-2b',
756
 
                  timestamp=1132586800, timezone=36000,
757
 
                  committer='Joe Foo <joe@foo.com>')
 
799
        wt = self._prepare_tree_with_merges()
758
800
        logfile = self.make_utf8_encoded_stringio()
759
801
        formatter = log.LineLogFormatter(to_file=logfile)
760
802
        revspec = revisionspec.RevisionSpec.from_string('1.1.1')
766
808
""",
767
809
                             logfile.getvalue())
768
810
 
 
811
    def test_line_log_with_tags(self):
 
812
        wt = self._prepare_tree_with_merges(with_tags=True)
 
813
        logfile = self.make_utf8_encoded_stringio()
 
814
        formatter = log.LineLogFormatter(to_file=logfile)
 
815
        log.show_log(wt.branch, formatter)
 
816
        self.assertEqualDiff("""\
 
817
3: Jane Foo 2005-11-22 {v1.0, v1.0rc1} rev-3
 
818
2: Joe Foo 2005-11-22 {v0.2} rev-2
 
819
1: Joe Foo 2005-11-22 rev-1
 
820
""",
 
821
                             logfile.getvalue())
769
822
 
770
823
 
771
824
class TestGetViewRevisions(tests.TestCaseWithTransport):