91
91
self.assertRaises(InvalidRevisionNumber, show_log, b, lf,
92
92
start_revision=1, end_revision=-1)
94
def test_cur_revno(self):
95
wt = self.make_branch_and_tree('.')
99
wt.commit('empty commit')
100
show_log(b, lf, verbose=True, start_revision=1, end_revision=1)
101
self.assertRaises(InvalidRevisionNumber, show_log, b, lf,
102
start_revision=2, end_revision=1)
103
self.assertRaises(InvalidRevisionNumber, show_log, b, lf,
104
start_revision=1, end_revision=2)
105
self.assertRaises(InvalidRevisionNumber, show_log, b, lf,
106
start_revision=0, end_revision=2)
107
self.assertRaises(InvalidRevisionNumber, show_log, b, lf,
108
start_revision=1, end_revision=0)
109
self.assertRaises(InvalidRevisionNumber, show_log, b, lf,
110
start_revision=-1, end_revision=1)
111
self.assertRaises(InvalidRevisionNumber, show_log, b, lf,
112
start_revision=1, end_revision=-1)
94
114
def test_simple_log(self):
95
115
eq = self.assertEquals
296
316
rev_nos = {'1': 1, '2': 2, '3': 3}
297
317
return mainline_revs, rev_nos, wt
319
def pseudo_merge(self, source, target):
320
revision_id = source.last_revision()
321
target.branch.fetch(source.branch, revision_id)
322
target.add_pending_merge(revision_id)
299
324
def make_tree_with_merges(self):
300
325
"""Create a tree with well-known revision ids and a merge"""
301
326
mainline_revs, rev_nos, wt = self.make_tree_with_commits()
302
327
tree2 = wt.bzrdir.sprout('tree2').open_workingtree()
303
328
tree2.commit('four-a', rev_id='4a')
304
wt.merge_from_branch(tree2.branch)
329
self.pseudo_merge(tree2, wt)
305
330
wt.commit('four-b', rev_id='4b')
306
331
mainline_revs.append('4b')
307
332
rev_nos['4b'] = 4
309
333
return mainline_revs, rev_nos, wt
311
335
def make_tree_with_many_merges(self):
313
337
wt = self.make_branch_and_tree('tree1')
314
338
wt.commit('commit one', rev_id='1')
315
339
wt.commit('commit two', rev_id='2')
340
tree2 = wt.bzrdir.sprout('tree2').open_workingtree()
316
341
tree3 = wt.bzrdir.sprout('tree3').open_workingtree()
317
342
tree3.commit('commit three a', rev_id='3a')
318
tree2 = wt.bzrdir.sprout('tree2').open_workingtree()
319
tree2.merge_from_branch(tree3.branch)
343
self.pseudo_merge(tree3, tree2)
320
344
tree2.commit('commit three b', rev_id='3b')
321
wt.merge_from_branch(tree2.branch)
345
self.pseudo_merge(tree2, wt)
322
346
wt.commit('commit three c', rev_id='3c')
323
347
tree2.commit('four-a', rev_id='4a')
324
wt.merge_from_branch(tree2.branch)
348
self.pseudo_merge(tree2, wt)
325
349
wt.commit('four-b', rev_id='4b')
326
350
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
351
rev_nos = {'1': 1, '2': 2, '3c': 3, '4b': 4}
337
352
return mainline_revs, rev_nos, wt
339
354
def test_get_view_revisions_forward(self):
352
366
mainline_revs, rev_nos, wt = self.make_tree_with_commits()
353
367
revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
355
self.assertEqual([('3', '3', 0), ('2', '2', 0), ('1', '1', 0), ],
369
self.assertEqual(revisions, [('3', 3, 0), ('2', 2, 0), ('1', 1, 0), ])
357
370
revisions2 = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
358
371
'reverse', include_merges=False))
359
372
self.assertEqual(revisions, revisions2)
363
376
mainline_revs, rev_nos, wt = self.make_tree_with_merges()
364
377
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)],
379
self.assertEqual(revisions, [('1', 1, 0), ('2', 2, 0), ('3', 3, 0),
380
('4b', 4, 0), ('4a', None, 1)])
369
381
revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
370
382
'forward', include_merges=False))
371
self.assertEqual([('1', '1', 0), ('2', '2', 0), ('3', '3', 0),
383
self.assertEqual(revisions, [('1', 1, 0), ('2', 2, 0), ('3', 3, 0),
375
386
def test_get_view_revisions_merge_reverse(self):
376
387
"""Test get_view_revisions in reverse when there are merges"""
377
388
mainline_revs, rev_nos, wt = self.make_tree_with_merges()
378
389
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)],
391
self.assertEqual(revisions, [('4b', 4, 0), ('4a', None, 1),
392
('3', 3, 0), ('2', 2, 0), ('1', 1, 0)])
383
393
revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
384
394
'reverse', include_merges=False))
385
self.assertEqual([('4b', '4', 0), ('3', '3', 0), ('2', '2', 0),
395
self.assertEqual(revisions, [('4b', 4, 0), ('3', 3, 0), ('2', 2, 0),
389
398
def test_get_view_revisions_merge2(self):
390
399
"""Test get_view_revisions when there are merges"""
391
400
mainline_revs, rev_nos, wt = self.make_tree_with_many_merges()
392
401
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)
403
expected = [('1', 1, 0), ('2', 2, 0), ('3c', 3, 0), ('3a', None, 1),
404
('3b', None, 1), ('4b', 4, 0), ('4a', None, 1)]
405
self.assertEqual(revisions, expected)
398
406
revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
399
407
'forward', include_merges=False))
400
self.assertEqual([('1', '1', 0), ('2', '2', 0), ('3c', '3', 0),
408
self.assertEqual(revisions, [('1', 1, 0), ('2', 2, 0), ('3c', 3, 0),