287
def test_line_log(self):
288
"""Line log should show revno
292
wt = self.make_branch_and_tree('.')
294
self.build_tree(['a'])
296
b.nick = 'test-line-log'
297
wt.commit(message='add a',
298
timestamp=1132711707,
300
committer='Line-Log-Formatter Tester <test@line.log>')
301
logfile = file('out.tmp', 'w+')
302
formatter = LineLogFormatter(to_file=logfile)
303
show_log(b, formatter)
306
log_contents = logfile.read()
307
self.assertEqualDiff(log_contents, '1: Line-Log-Formatte... 2005-11-23 add a\n')
309
def make_tree_with_commits(self):
310
"""Create a tree with well-known revision ids"""
311
wt = self.make_branch_and_tree('tree1')
312
wt.commit('commit one', rev_id='1')
313
wt.commit('commit two', rev_id='2')
314
wt.commit('commit three', rev_id='3')
315
mainline_revs = [None, '1', '2', '3']
316
rev_nos = {'1': 1, '2': 2, '3': 3}
317
return mainline_revs, rev_nos, wt
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()
322
tree2 = wt.bzrdir.sprout('tree2').open_workingtree()
323
tree2.commit('four-a', rev_id='4a')
324
self.merge(tree2.branch, wt)
325
wt.commit('four-b', rev_id='4b')
326
mainline_revs.append('4b')
328
return mainline_revs, rev_nos, wt
330
def make_tree_with_many_merges(self):
331
"""Create a tree with well-known revision ids"""
332
wt = self.make_branch_and_tree('tree1')
333
wt.commit('commit one', rev_id='1')
334
wt.commit('commit two', rev_id='2')
335
tree2 = wt.bzrdir.sprout('tree2').open_workingtree()
336
tree3 = wt.bzrdir.sprout('tree3').open_workingtree()
337
tree3.commit('commit three a', rev_id='3a')
338
self.merge(tree3.branch, tree2)
339
tree2.commit('commit three b', rev_id='3b')
340
self.merge(tree2.branch, wt)
341
wt.commit('commit three c', rev_id='3c')
342
tree2.commit('four-a', rev_id='4a')
343
self.merge(tree2.branch, wt)
344
wt.commit('four-b', rev_id='4b')
345
mainline_revs = [None, '1', '2', '3c', '4b']
346
rev_nos = {'1': 1, '2': 2, '3c': 3, '4b': 4}
347
return mainline_revs, rev_nos, wt
349
def test_get_view_revisions_forward(self):
350
"""Test the get_view_revisions method"""
351
mainline_revs, rev_nos, wt = self.make_tree_with_commits()
352
revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
354
self.assertEqual(revisions, [('1', 1, 0), ('2', 2, 0), ('3', 3, 0)])
355
revisions2 = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
356
'forward', include_merges=False))
357
self.assertEqual(revisions, revisions2)
359
def test_get_view_revisions_reverse(self):
360
"""Test the get_view_revisions with reverse"""
361
mainline_revs, rev_nos, wt = self.make_tree_with_commits()
362
revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
364
self.assertEqual(revisions, [('3', 3, 0), ('2', 2, 0), ('1', 1, 0), ])
365
revisions2 = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
366
'reverse', include_merges=False))
367
self.assertEqual(revisions, revisions2)
369
def test_get_view_revisions_merge(self):
370
"""Test get_view_revisions when there are merges"""
371
mainline_revs, rev_nos, wt = self.make_tree_with_merges()
372
revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
374
self.assertEqual(revisions, [('1', 1, 0), ('2', 2, 0), ('3', 3, 0),
375
('4b', 4, 0), ('4a', None, 1)])
376
revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
377
'forward', include_merges=False))
378
self.assertEqual(revisions, [('1', 1, 0), ('2', 2, 0), ('3', 3, 0),
381
def test_get_view_revisions_merge_reverse(self):
382
"""Test get_view_revisions in reverse when there are merges"""
383
mainline_revs, rev_nos, wt = self.make_tree_with_merges()
384
revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
386
self.assertEqual(revisions, [('4b', 4, 0), ('4a', None, 1),
387
('3', 3, 0), ('2', 2, 0), ('1', 1, 0)])
388
revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
389
'reverse', include_merges=False))
390
self.assertEqual(revisions, [('4b', 4, 0), ('3', 3, 0), ('2', 2, 0),
393
def test_get_view_revisions_merge2(self):
394
"""Test get_view_revisions when there are merges"""
395
mainline_revs, rev_nos, wt = self.make_tree_with_many_merges()
396
revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
398
expected = [('1', 1, 0), ('2', 2, 0), ('3c', 3, 0), ('3a', None, 1),
399
('3b', None, 1), ('4b', 4, 0), ('4a', None, 1)]
400
self.assertEqual(revisions, expected)
401
revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
402
'forward', include_merges=False))
403
self.assertEqual(revisions, [('1', 1, 0), ('2', 2, 0), ('3c', 3, 0),