/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_log.py

  • Committer: Matt Nordhoff
  • Date: 2009-04-04 02:50:01 UTC
  • mfrom: (4253 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4256.
  • Revision ID: mnordhoff@mattnordhoff.com-20090404025001-z1403k0tatmc8l91
Merge bzr.dev, fixing conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
import os
18
18
from cStringIO import StringIO
198
198
        self.assertEqual('add file1 and file2', logentry.rev.message)
199
199
        self.checkDelta(logentry.delta, added=['file1', 'file2'])
200
200
 
201
 
    def test_merges_nonsupporting_formatter(self):
202
 
        """Tests that show_log will raise if the formatter doesn't
203
 
        support merge revisions."""
204
 
        wt = self.make_branch_and_memory_tree('.')
205
 
        wt.lock_write()
206
 
        self.addCleanup(wt.unlock)
207
 
        wt.add('')
208
 
        wt.commit('rev-1', rev_id='rev-1',
209
 
                  timestamp=1132586655, timezone=36000,
210
 
                  committer='Joe Foo <joe@foo.com>')
211
 
        wt.commit('rev-merged', rev_id='rev-2a',
212
 
                  timestamp=1132586700, timezone=36000,
213
 
                  committer='Joe Foo <joe@foo.com>')
214
 
        wt.set_parent_ids(['rev-1', 'rev-2a'])
215
 
        wt.branch.set_last_revision_info(1, 'rev-1')
216
 
        wt.commit('rev-2', rev_id='rev-2b',
217
 
                  timestamp=1132586800, timezone=36000,
218
 
                  committer='Joe Foo <joe@foo.com>')
219
 
        logfile = self.make_utf8_encoded_stringio()
220
 
        formatter = log.ShortLogFormatter(to_file=logfile)
221
 
        wtb = wt.branch
222
 
        lf = LogCatcher()
223
 
        revspec = revisionspec.RevisionSpec.from_string('1.1.1')
224
 
        rev = revspec.in_history(wtb)
225
 
        self.assertRaises(errors.BzrCommandError, log.show_log, wtb, lf,
226
 
                          start_revision=rev, end_revision=rev)
227
 
 
228
201
 
229
202
def make_commits_with_trailing_newlines(wt):
230
203
    """Helper method for LogFormatter tests"""
240
213
    wt.commit('multiline\nlog\nmessage\n', rev_id='a2',
241
214
              timestamp=1132586842.411175966, timezone=-6*3600,
242
215
              committer='Joe Foo <joe@foo.com>',
243
 
              author='Joe Bar <joe@bar.com>')
 
216
              authors=['Joe Bar <joe@bar.com>'])
244
217
 
245
218
    open('c', 'wb').write('just another manic monday\n')
246
219
    wt.add('c')
328
301
    1 Joe Foo\t2005-11-22
329
302
      rev-1
330
303
 
 
304
Use --levels 0 (or -n0) to see merged revisions.
331
305
""",
332
306
                             logfile.getvalue())
333
307
 
366
340
    2 Joe Foo\t2005-11-22 [merge]
367
341
      rev-2b
368
342
 
 
343
Use --levels 0 (or -n0) to see merged revisions.
369
344
""",
370
345
                             logfile.getvalue())
371
346
 
384
359
    1 Joe Foo\t2005-11-22
385
360
      rev-1
386
361
 
 
362
Use --levels 0 (or -n0) to see merged revisions.
387
363
""",
388
364
                             logfile.getvalue())
389
365
 
488
464
 
489
465
    def test_verbose_log(self):
490
466
        """Verbose log includes changed files
491
 
        
 
467
 
492
468
        bug #4676
493
469
        """
494
470
        wt = self.make_branch_and_tree('.')
536
512
        wt.commit('merge branch 1')
537
513
        b = wt.branch
538
514
        sio = self.make_utf8_encoded_stringio()
539
 
        lf = log.LongLogFormatter(to_file=sio)
 
515
        lf = log.LongLogFormatter(to_file=sio, levels=0)
540
516
        log.show_log(b, lf, verbose=True)
541
517
        the_log = normalize_log(sio.getvalue())
542
518
        self.assertEqualDiff("""\
543
519
------------------------------------------------------------
544
 
revno: 2
 
520
revno: 2 [merge]
545
521
committer: Lorem Ipsum <test@example.com>
546
522
branch nick: parent
547
523
timestamp: Just now
548
524
message:
549
525
  merge branch 1
550
526
    ------------------------------------------------------------
551
 
    revno: 1.1.2
 
527
    revno: 1.1.2 [merge]
552
528
    committer: Lorem Ipsum <test@example.com>
553
529
    branch nick: child
554
530
    timestamp: Just now
593
569
        wt.commit('merge branch 1')
594
570
        b = wt.branch
595
571
        sio = self.make_utf8_encoded_stringio()
596
 
        lf = log.LongLogFormatter(to_file=sio)
 
572
        lf = log.LongLogFormatter(to_file=sio, levels=0)
597
573
        log.show_log(b, lf, verbose=True)
598
574
        the_log = normalize_log(sio.getvalue())
599
575
        self.assertEqualDiff("""\
600
576
------------------------------------------------------------
601
 
revno: 2
 
577
revno: 2 [merge]
602
578
committer: Lorem Ipsum <test@example.com>
603
579
branch nick: parent
604
580
timestamp: Just now
679
655
                  timestamp=1132711707,
680
656
                  timezone=36000,
681
657
                  committer='Lorem Ipsum <test@example.com>',
682
 
                  author='John Doe <jdoe@example.com>')
 
658
                  authors=['John Doe <jdoe@example.com>',
 
659
                           'Jane Rey <jrey@example.com>'])
683
660
        sio = StringIO()
684
661
        formatter = log.LongLogFormatter(to_file=sio)
685
662
        log.show_log(b, formatter)
686
663
        self.assertEqualDiff('''\
687
664
------------------------------------------------------------
688
665
revno: 1
689
 
author: John Doe <jdoe@example.com>
 
666
author: John Doe <jdoe@example.com>, Jane Rey <jrey@example.com>
690
667
committer: Lorem Ipsum <test@example.com>
691
668
branch nick: test_author_log
692
669
timestamp: Wed 2005-11-23 12:08:27 +1000
696
673
                             sio.getvalue())
697
674
 
698
675
    def test_properties_in_log(self):
699
 
        """Log includes the custom properties returned by the registered 
 
676
        """Log includes the custom properties returned by the registered
700
677
        handlers.
701
678
        """
702
679
        wt = self.make_branch_and_tree('.')
708
685
                  timestamp=1132711707,
709
686
                  timezone=36000,
710
687
                  committer='Lorem Ipsum <test@example.com>',
711
 
                  author='John Doe <jdoe@example.com>')
 
688
                  authors=['John Doe <jdoe@example.com>'])
712
689
        sio = StringIO()
713
690
        formatter = log.LongLogFormatter(to_file=sio)
714
691
        try:
736
713
                                 sio.getvalue())
737
714
 
738
715
    def test_properties_in_short_log(self):
739
 
        """Log includes the custom properties returned by the registered 
 
716
        """Log includes the custom properties returned by the registered
740
717
        handlers.
741
718
        """
742
719
        wt = self.make_branch_and_tree('.')
748
725
                  timestamp=1132711707,
749
726
                  timezone=36000,
750
727
                  committer='Lorem Ipsum <test@example.com>',
751
 
                  author='John Doe <jdoe@example.com>')
 
728
                  authors=['John Doe <jdoe@example.com>'])
752
729
        sio = StringIO()
753
730
        formatter = log.ShortLogFormatter(to_file=sio)
754
731
        try:
771
748
                                 sio.getvalue())
772
749
 
773
750
    def test_error_in_properties_handler(self):
774
 
        """Log includes the custom properties returned by the registered 
 
751
        """Log includes the custom properties returned by the registered
775
752
        handlers.
776
753
        """
777
754
        wt = self.make_branch_and_tree('.')
783
760
                  timestamp=1132711707,
784
761
                  timezone=36000,
785
762
                  committer='Lorem Ipsum <test@example.com>',
786
 
                  author='John Doe <jdoe@example.com>',
 
763
                  authors=['John Doe <jdoe@example.com>'],
787
764
                  revprops={'first_prop':'first_value'})
788
765
        sio = StringIO()
789
766
        formatter = log.LongLogFormatter(to_file=sio)
809
786
                  timestamp=1132711707,
810
787
                  timezone=36000,
811
788
                  committer='Lorem Ipsum <test@example.com>',
812
 
                  author='John Doe <jdoe@example.com>',
 
789
                  authors=['John Doe <jdoe@example.com>'],
813
790
                  revprops={'a_prop':'test_value'})
814
791
        sio = StringIO()
815
792
        formatter = log.LongLogFormatter(to_file=sio)
837
814
 
838
815
    def test_long_verbose_log(self):
839
816
        """Verbose log includes changed files
840
 
        
 
817
 
841
818
        bug #4676
842
819
        """
843
820
        wt = self.make_branch_and_tree('.')
889
866
        the_log = normalize_log(sio.getvalue())
890
867
        self.assertEqualDiff("""\
891
868
------------------------------------------------------------
892
 
revno: 2
 
869
revno: 2 [merge]
893
870
committer: Lorem Ipsum <test@example.com>
894
871
branch nick: parent
895
872
timestamp: Just now
909
886
added:
910
887
  f1
911
888
  f2
 
889
------------------------------------------------------------
 
890
Use --levels 0 (or -n0) to see merged revisions.
912
891
""",
913
892
                             the_log)
914
893
 
959
938
                  timestamp=1132711707,
960
939
                  timezone=36000,
961
940
                  committer='Lorem Ipsum <test@example.com>',
962
 
                  author='John Doe <jdoe@example.com>')
 
941
                  authors=['John Doe <jdoe@example.com>'])
963
942
        sio = StringIO()
964
943
        formatter = log.LongLogFormatter(to_file=sio, levels=1)
965
944
        log.show_log(b, formatter)
976
955
                             sio.getvalue())
977
956
 
978
957
    def test_long_properties_in_log(self):
979
 
        """Log includes the custom properties returned by the registered 
 
958
        """Log includes the custom properties returned by the registered
980
959
        handlers.
981
960
        """
982
961
        wt = self.make_branch_and_tree('.')
988
967
                  timestamp=1132711707,
989
968
                  timezone=36000,
990
969
                  committer='Lorem Ipsum <test@example.com>',
991
 
                  author='John Doe <jdoe@example.com>')
 
970
                  authors=['John Doe <jdoe@example.com>'])
992
971
        sio = StringIO()
993
972
        formatter = log.LongLogFormatter(to_file=sio, levels=1)
994
973
        try:
1020
999
 
1021
1000
    def test_line_log(self):
1022
1001
        """Line log should show revno
1023
 
        
 
1002
 
1024
1003
        bug #5162
1025
1004
        """
1026
1005
        wt = self.make_branch_and_tree('.')
1109
1088
 
1110
1089
    def test_line_merge_revs_log(self):
1111
1090
        """Line log should show revno
1112
 
        
 
1091
 
1113
1092
        bug #5162
1114
1093
        """
1115
1094
        wt = self.make_branch_and_tree('.')
1341
1320
                direction, # direction
1342
1321
                file_id, # specific_fileid
1343
1322
                True, # generate_merge_revisions
1344
 
                True, # allow_single_merge_revision
1345
1323
                )
1346
1324
            return revs
1347
1325
 
1498
1476
        self.assertAllRevisionsForFileID(tree, 'f1-id', ['XX', 'B', 'A'])
1499
1477
        self.assertAllRevisionsForFileID(tree, 'f2-id', ['D', 'C', 'A'])
1500
1478
 
 
1479
    def test_unknown_file_id(self):
 
1480
        tree = self.create_tree_with_single_merge()
 
1481
        self.assertAllRevisionsForFileID(tree, 'unknown', [])
 
1482
 
 
1483
    def test_empty_branch_unknown_file_id(self):
 
1484
        tree = self.make_branch_and_tree('tree')
 
1485
        self.assertAllRevisionsForFileID(tree, 'unknown', [])
 
1486
 
1501
1487
 
1502
1488
class TestShowChangedRevisions(tests.TestCaseWithTransport):
1503
1489
 
1545
1531
        self.assertEqual('jsmith@example.com', lf.short_author(rev))
1546
1532
        rev.properties['author'] = 'John Smith jsmith@example.com'
1547
1533
        self.assertEqual('John Smith', lf.short_author(rev))
 
1534
        del rev.properties['author']
 
1535
        rev.properties['authors'] = ('John Smith <jsmith@example.com>\n'
 
1536
                'Jane Rey <jrey@example.com>')
 
1537
        self.assertEqual('John Smith', lf.short_author(rev))
1548
1538
 
1549
1539
 
1550
1540
class TestReverseByDepth(tests.TestCase):