343
344
wt.merge_from_branch(tree2.branch)
344
345
wt.commit('four-b', rev_id='4b')
345
346
mainline_revs = [None, '1', '2', '3c', '4b']
346
rev_nos = {'1': 1, '2': 2, '3c': 3, '4b': 4}
347
rev_nos = {'1':1, '2':2, '3c': 3, '4b':4}
348
full_rev_nos_for_reference = {
351
'3a': '2.2.1', #first commit tree 3
352
'3b': '2.1.1', # first commit tree 2
353
'3c': '3', #merges 3b to main
354
'4a': '2.1.2', # second commit tree 2
355
'4b': '4', # merges 4a to main
347
357
return mainline_revs, rev_nos, wt
349
359
def test_get_view_revisions_forward(self):
361
372
mainline_revs, rev_nos, wt = self.make_tree_with_commits()
362
373
revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
364
self.assertEqual(revisions, [('3', 3, 0), ('2', 2, 0), ('1', 1, 0), ])
375
self.assertEqual([('3', '3', 0), ('2', '2', 0), ('1', '1', 0), ],
365
377
revisions2 = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
366
378
'reverse', include_merges=False))
367
379
self.assertEqual(revisions, revisions2)
371
383
mainline_revs, rev_nos, wt = self.make_tree_with_merges()
372
384
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)])
386
self.assertEqual([('1', '1', 0), ('2', '2', 0), ('3', '3', 0),
387
('4b', '4', 0), ('4a', '3.1.1', 1)],
376
389
revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
377
390
'forward', include_merges=False))
378
self.assertEqual(revisions, [('1', 1, 0), ('2', 2, 0), ('3', 3, 0),
391
self.assertEqual([('1', '1', 0), ('2', '2', 0), ('3', '3', 0),
381
395
def test_get_view_revisions_merge_reverse(self):
382
396
"""Test get_view_revisions in reverse when there are merges"""
383
397
mainline_revs, rev_nos, wt = self.make_tree_with_merges()
384
398
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)])
400
self.assertEqual([('4b', '4', 0), ('4a', '3.1.1', 1),
401
('3', '3', 0), ('2', '2', 0), ('1', '1', 0)],
388
403
revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
389
404
'reverse', include_merges=False))
390
self.assertEqual(revisions, [('4b', 4, 0), ('3', 3, 0), ('2', 2, 0),
405
self.assertEqual([('4b', '4', 0), ('3', '3', 0), ('2', '2', 0),
393
409
def test_get_view_revisions_merge2(self):
394
410
"""Test get_view_revisions when there are merges"""
395
411
mainline_revs, rev_nos, wt = self.make_tree_with_many_merges()
396
412
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)
414
expected = [('1', '1', 0), ('2', '2', 0), ('3c', '3', 0),
415
('3a', '2.2.1', 1), ('3b', '2.1.1', 1), ('4b', '4', 0),
417
self.assertEqual(expected, revisions)
401
418
revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
402
419
'forward', include_merges=False))
403
self.assertEqual(revisions, [('1', 1, 0), ('2', 2, 0), ('3c', 3, 0),
420
self.assertEqual([('1', '1', 0), ('2', '2', 0), ('3c', '3', 0),