60
60
return "Nothing to see."
63
class FakeLock(object):
65
def __init__(self, unlock):
71
def __exit__(self, exc_type, exc_val, exc_tb):
63
76
class LockableStub(object):
65
78
def __init__(self):
421
435
# check loom threads
422
436
threads = target.get_loom_state().get_threads()
423
437
self.assertEqual(
424
[('a thread', 'empty:', ['empty:'])],
438
[('a thread', b'empty:', [b'empty:'])],
426
440
# check loom tip was pulled
427
441
loom_rev_ids = source.branch.loom_parents()
525
539
tree.branch.revert_loom()
526
540
# the threads list should be restored
527
541
self.assertEqual(
528
[(u'foo', 'empty:', [EMPTY_REVISION]),
542
[(u'foo', b'empty:', [EMPTY_REVISION]),
529
543
(u'bar', last_rev, [last_rev])],
530
544
tree.branch.get_loom_state().get_threads())
531
545
self.assertEqual(last_rev, tree.branch.last_revision())
552
566
tree.branch.revert_loom()
553
567
# the threads list should be restored
554
568
self.assertEqual(
555
[('base', 'empty:', [EMPTY_REVISION]),
569
[('base', b'empty:', [EMPTY_REVISION]),
556
570
('top', last_rev, [last_rev])],
557
571
tree.branch.get_loom_state().get_threads())
558
572
self.assertEqual(last_rev, tree.branch.last_revision())
597
611
tree.branch._set_nick('bar')
598
612
tree.branch.remove_thread('foo')
599
613
state = tree.branch.get_loom_state()
600
self.assertEqual([('bar', 'empty:', [])], state.get_threads())
614
self.assertEqual([('bar', b'empty:', [])], state.get_threads())
602
616
def test_get_threads_null(self):
603
617
tree = self.get_tree_with_loom()
613
627
tree = self.get_tree_with_loom()
614
628
tree.branch.new_thread('thread1')
615
629
tree.branch._set_nick('thread1')
616
tree.commit('thread1', rev_id='thread1-id')
630
tree.commit('thread1', rev_id=b'thread1-id')
617
631
tree.branch.new_thread('thread2', 'thread1')
618
632
tree.branch._set_nick('thread2')
619
tree.commit('thread2', rev_id='thread2-id')
633
tree.commit('thread2', rev_id=b'thread2-id')
622
636
def test_export_loom_initial(self):
624
638
root_transport = tree.branch.controldir.root_transport
625
639
tree.branch.export_threads(root_transport)
626
640
thread1 = Branch.open_from_transport(root_transport.clone('thread1'))
627
self.assertEqual('thread1-id', thread1.last_revision())
641
self.assertEqual(b'thread1-id', thread1.last_revision())
628
642
thread2 = Branch.open_from_transport(root_transport.clone('thread2'))
629
self.assertEqual('thread2-id', thread2.last_revision())
643
self.assertEqual(b'thread2-id', thread2.last_revision())
631
645
def test_export_loom_update(self):
632
646
tree = self.get_multi_threaded()
633
647
root_transport = tree.branch.controldir.root_transport
634
648
tree.branch.export_threads(root_transport)
635
tree.commit('thread2-2', rev_id='thread2-2-id')
649
tree.commit('thread2-2', rev_id=b'thread2-2-id')
636
650
tree.branch.export_threads(root_transport)
637
651
thread1 = Branch.open_from_transport(root_transport.clone('thread1'))
638
self.assertEqual('thread1-id', thread1.last_revision())
652
self.assertEqual(b'thread1-id', thread1.last_revision())
639
653
thread2 = Branch.open_from_transport(root_transport.clone('thread2'))
640
self.assertEqual('thread2-2-id', thread2.last_revision())
654
self.assertEqual(b'thread2-2-id', thread2.last_revision())
642
656
def test_export_loom_root_transport(self):
643
657
tree = self.get_multi_threaded()
646
660
tree.branch.export_threads(root_transport)
647
661
thread1 = Branch.open_from_transport(root_transport.clone('thread1'))
648
662
thread1 = Branch.open_from_transport(root_transport.clone('thread1'))
649
self.assertEqual('thread1-id', thread1.last_revision())
663
self.assertEqual(b'thread1-id', thread1.last_revision())
650
664
thread2 = Branch.open_from_transport(root_transport.clone('thread2'))
651
self.assertEqual('thread2-id', thread2.last_revision())
665
self.assertEqual(b'thread2-id', thread2.last_revision())
653
667
def test_export_loom_as_tree(self):
654
668
tree = self.get_multi_threaded()
656
670
root_transport = tree.branch.controldir.root_transport.clone('root')
657
671
tree.branch.export_threads(root_transport)
658
672
export_tree = WorkingTree.open(root_transport.local_abspath('thread1'))
659
self.assertEqual('thread1-id', export_tree.last_revision())
673
self.assertEqual(b'thread1-id', export_tree.last_revision())
661
675
def test_export_loom_as_branch(self):
662
676
tree = self.get_multi_threaded()
670
684
root_transport.local_abspath('thread1'))
671
685
export_branch = Branch.open_from_transport(
672
686
root_transport.clone('thread1'))
673
self.assertEqual('thread1-id', export_branch.last_revision())
687
self.assertEqual(b'thread1-id', export_branch.last_revision())
675
689
def test_set_nick_renames_thread(self):
676
690
tree = self.get_tree_with_loom()