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
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'])
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('.')
206
self.addCleanup(wt.unlock)
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)
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)
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>'])
245
218
open('c', 'wb').write('just another manic monday\n')
536
512
wt.commit('merge branch 1')
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
------------------------------------------------------------
545
521
committer: Lorem Ipsum <test@example.com>
546
522
branch nick: parent
547
523
timestamp: Just now
550
526
------------------------------------------------------------
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')
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
------------------------------------------------------------
602
578
committer: Lorem Ipsum <test@example.com>
603
579
branch nick: parent
604
580
timestamp: Just now
679
655
timestamp=1132711707,
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>'])
684
661
formatter = log.LongLogFormatter(to_file=sio)
685
662
log.show_log(b, formatter)
686
663
self.assertEqualDiff('''\
687
664
------------------------------------------------------------
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
708
685
timestamp=1132711707,
710
687
committer='Lorem Ipsum <test@example.com>',
711
author='John Doe <jdoe@example.com>')
688
authors=['John Doe <jdoe@example.com>'])
713
690
formatter = log.LongLogFormatter(to_file=sio)
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
742
719
wt = self.make_branch_and_tree('.')
748
725
timestamp=1132711707,
750
727
committer='Lorem Ipsum <test@example.com>',
751
author='John Doe <jdoe@example.com>')
728
authors=['John Doe <jdoe@example.com>'])
753
730
formatter = log.ShortLogFormatter(to_file=sio)
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
777
754
wt = self.make_branch_and_tree('.')
783
760
timestamp=1132711707,
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'})
789
766
formatter = log.LongLogFormatter(to_file=sio)
809
786
timestamp=1132711707,
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'})
815
792
formatter = log.LongLogFormatter(to_file=sio)
959
938
timestamp=1132711707,
961
940
committer='Lorem Ipsum <test@example.com>',
962
author='John Doe <jdoe@example.com>')
941
authors=['John Doe <jdoe@example.com>'])
964
943
formatter = log.LongLogFormatter(to_file=sio, levels=1)
965
944
log.show_log(b, formatter)
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
982
961
wt = self.make_branch_and_tree('.')
988
967
timestamp=1132711707,
990
969
committer='Lorem Ipsum <test@example.com>',
991
author='John Doe <jdoe@example.com>')
970
authors=['John Doe <jdoe@example.com>'])
993
972
formatter = log.LongLogFormatter(to_file=sio, levels=1)
1498
1476
self.assertAllRevisionsForFileID(tree, 'f1-id', ['XX', 'B', 'A'])
1499
1477
self.assertAllRevisionsForFileID(tree, 'f2-id', ['D', 'C', 'A'])
1479
def test_unknown_file_id(self):
1480
tree = self.create_tree_with_single_merge()
1481
self.assertAllRevisionsForFileID(tree, 'unknown', [])
1483
def test_empty_branch_unknown_file_id(self):
1484
tree = self.make_branch_and_tree('tree')
1485
self.assertAllRevisionsForFileID(tree, 'unknown', [])
1502
1488
class TestShowChangedRevisions(tests.TestCaseWithTransport):
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))
1550
1540
class TestReverseByDepth(tests.TestCase):