84
91
self.assertRaises(InvalidRevisionNumber, show_log, b, lf,
85
92
start_revision=1, end_revision=-1)
87
def test_cur_revno(self):
88
wt = self.make_branch_and_tree('.')
92
wt.commit('empty commit')
93
show_log(b, lf, verbose=True, start_revision=1, end_revision=1)
94
self.assertRaises(InvalidRevisionNumber, show_log, b, lf,
95
start_revision=2, end_revision=1)
96
self.assertRaises(InvalidRevisionNumber, show_log, b, lf,
97
start_revision=1, end_revision=2)
98
self.assertRaises(InvalidRevisionNumber, show_log, b, lf,
99
start_revision=0, end_revision=2)
100
self.assertRaises(InvalidRevisionNumber, show_log, b, lf,
101
start_revision=1, end_revision=0)
102
self.assertRaises(InvalidRevisionNumber, show_log, b, lf,
103
start_revision=-1, end_revision=1)
104
self.assertRaises(InvalidRevisionNumber, show_log, b, lf,
105
start_revision=1, end_revision=-1)
107
94
def test_simple_log(self):
108
95
eq = self.assertEquals
299
286
log_contents = logfile.read()
300
287
self.assertEqualDiff(log_contents, '1: Line-Log-Formatte... 2005-11-23 add a\n')
289
def make_tree_with_commits(self):
290
"""Create a tree with well-known revision ids"""
291
wt = self.make_branch_and_tree('tree1')
292
wt.commit('commit one', rev_id='1')
293
wt.commit('commit two', rev_id='2')
294
wt.commit('commit three', rev_id='3')
295
mainline_revs = [None, '1', '2', '3']
296
rev_nos = {'1': 1, '2': 2, '3': 3}
297
return mainline_revs, rev_nos, wt
299
def make_tree_with_merges(self):
300
"""Create a tree with well-known revision ids and a merge"""
301
mainline_revs, rev_nos, wt = self.make_tree_with_commits()
302
tree2 = wt.bzrdir.sprout('tree2').open_workingtree()
303
tree2.commit('four-a', rev_id='4a')
304
wt.merge_from_branch(tree2.branch)
305
wt.commit('four-b', rev_id='4b')
306
mainline_revs.append('4b')
309
return mainline_revs, rev_nos, wt
311
def make_tree_with_many_merges(self):
312
"""Create a tree with well-known revision ids"""
313
wt = self.make_branch_and_tree('tree1')
314
wt.commit('commit one', rev_id='1')
315
wt.commit('commit two', rev_id='2')
316
tree3 = wt.bzrdir.sprout('tree3').open_workingtree()
317
tree3.commit('commit three a', rev_id='3a')
318
tree2 = wt.bzrdir.sprout('tree2').open_workingtree()
319
tree2.merge_from_branch(tree3.branch)
320
tree2.commit('commit three b', rev_id='3b')
321
wt.merge_from_branch(tree2.branch)
322
wt.commit('commit three c', rev_id='3c')
323
tree2.commit('four-a', rev_id='4a')
324
wt.merge_from_branch(tree2.branch)
325
wt.commit('four-b', rev_id='4b')
326
mainline_revs = [None, '1', '2', '3c', '4b']
327
rev_nos = {'1':1, '2':2, '3c': 3, '4b':4}
328
full_rev_nos_for_reference = {
331
'3a': '2.2.1', #first commit tree 3
332
'3b': '2.1.1', # first commit tree 2
333
'3c': '3', #merges 3b to main
334
'4a': '2.1.2', # second commit tree 2
335
'4b': '4', # merges 4a to main
337
return mainline_revs, rev_nos, wt
339
def test_get_view_revisions_forward(self):
340
"""Test the get_view_revisions method"""
341
mainline_revs, rev_nos, wt = self.make_tree_with_commits()
342
revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
344
self.assertEqual([('1', '1', 0), ('2', '2', 0), ('3', '3', 0)],
346
revisions2 = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
347
'forward', include_merges=False))
348
self.assertEqual(revisions, revisions2)
350
def test_get_view_revisions_reverse(self):
351
"""Test the get_view_revisions with reverse"""
352
mainline_revs, rev_nos, wt = self.make_tree_with_commits()
353
revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
355
self.assertEqual([('3', '3', 0), ('2', '2', 0), ('1', '1', 0), ],
357
revisions2 = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
358
'reverse', include_merges=False))
359
self.assertEqual(revisions, revisions2)
361
def test_get_view_revisions_merge(self):
362
"""Test get_view_revisions when there are merges"""
363
mainline_revs, rev_nos, wt = self.make_tree_with_merges()
364
revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
366
self.assertEqual([('1', '1', 0), ('2', '2', 0), ('3', '3', 0),
367
('4b', '4', 0), ('4a', '3.1.1', 1)],
369
revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
370
'forward', include_merges=False))
371
self.assertEqual([('1', '1', 0), ('2', '2', 0), ('3', '3', 0),
375
def test_get_view_revisions_merge_reverse(self):
376
"""Test get_view_revisions in reverse when there are merges"""
377
mainline_revs, rev_nos, wt = self.make_tree_with_merges()
378
revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
380
self.assertEqual([('4b', '4', 0), ('4a', '3.1.1', 1),
381
('3', '3', 0), ('2', '2', 0), ('1', '1', 0)],
383
revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
384
'reverse', include_merges=False))
385
self.assertEqual([('4b', '4', 0), ('3', '3', 0), ('2', '2', 0),
389
def test_get_view_revisions_merge2(self):
390
"""Test get_view_revisions when there are merges"""
391
mainline_revs, rev_nos, wt = self.make_tree_with_many_merges()
392
revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
394
expected = [('1', '1', 0), ('2', '2', 0), ('3c', '3', 0),
395
('3a', '2.2.1', 1), ('3b', '2.1.1', 1), ('4b', '4', 0),
397
self.assertEqual(expected, revisions)
398
revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
399
'forward', include_merges=False))
400
self.assertEqual([('1', '1', 0), ('2', '2', 0), ('3c', '3', 0),