def test_revert_loom_remove_current_thread_mid_loom(self):
     # given the loom Base, => mid, top, with a basis of Base, top, revert
     # of the loom should end up with Base, =>top, including last-revision
     # changes
     tree = self.get_tree_with_loom()
     tree = LoomTreeDecorator(tree)
     # new threads
     tree.branch.new_thread('base')
     tree.branch.new_thread('top')
     tree.branch._set_nick('top')
     # and a change to the revision history of this thread
     tree.tree.commit('change top', allow_pointless=True)
     last_rev = tree.branch.last_revision()
     # now record
     tree.branch.record_loom('change top')
     tree.down_thread()
     tree.branch.new_thread('middle', 'base')
     tree.up_thread()
     self.assertEqual('middle', tree.branch.nick)
     tree.branch.revert_loom()
     # the threads list should be restored
     self.assertEqual(
         [('base', b'empty:', [EMPTY_REVISION]),
          ('top', last_rev, [last_rev])],
         tree.branch.get_loom_state().get_threads())
     self.assertEqual(last_rev, tree.branch.last_revision())
 def test_push_loom_loom(self):
     """Pushing a loom to a loom copies the current loom state."""
     source = self.get_tree_with_loom('source')
     source.branch.new_thread('bottom')
     source.branch.new_thread('top')
     source.branch._set_nick('bottom')
     source.branch.record_loom('commit to loom')
     target = source.controldir.sprout('target').open_branch()
     target._set_nick('top')
     # put a commit in the bottom and top of this loom
     bottom_rev1 = source.commit('commit bottom')
     source_loom_tree = LoomTreeDecorator(source)
     source_loom_tree.up_thread()
     top_rev1 = source.commit('integrate bottom changes.')
     source_loom_tree.down_thread()
     # and now another commit at the bottom
     bottom_rev2 = source.commit('bottom 2', allow_pointless=True)
     source.branch.record_loom('commit to loom again')
     # we now have two commits in the bottom warp, one in the top, and
     # all three should be pulled. We are pushing into a loom which has
     # a different current thread too : that should not affect us.
     source.branch.push(target)
     for rev in (bottom_rev1, bottom_rev2, top_rev1):
         self.assertTrue(target.repository.has_revision(rev))
     # check loom threads
     threads = target.get_loom_state().get_threads()
     self.assertEqual(
         [('bottom', bottom_rev2, [bottom_rev2]),
          ('top', top_rev1, [top_rev1])],
         threads)
     # check loom tip was pulled
     loom_rev_ids = source.branch.loom_parents()
     for rev_id in loom_rev_ids:
         self.assertTrue(target.repository.has_revision(rev_id))
     self.assertEqual(source.branch.loom_parents(), target.loom_parents())
Exemple #3
0
 def get_two_thread_loom(self):
     tree = self.get_vendor_loom()
     tree.branch.new_thread('above-vendor')
     loom_tree = LoomTreeDecorator(tree)
     loom_tree.up_thread()
     self.build_tree(['file-a'])
     tree.add('file-a')
     tree.commit('change the tree', rev_id=b'above-vendor-1')
     loom_tree.down_thread()
     return tree, loom_tree
Exemple #4
0
 def test_switch_thread_up_does_not_merge(self):
     tree = self.get_vendor_loom()
     self._add_patch(tree, 'thread1')
     rev_id = self._add_patch(tree, 'thread2')
     loom_tree = LoomTreeDecorator(tree)
     loom_tree.down_thread('vendor')
     out, err = self.run_bzr(['switch', 'thread2'], retcode=0)
     self.assertEqual('', out)
     self.assertEqual(
         "All changes applied successfully.\nMoved to thread 'thread2'.\n",
         err)
     self.assertEqual([rev_id], tree.get_parent_ids())
Exemple #5
0
    def get_loom_with_unique_thread(self):
        """Return a loom with a unique thread.

        That is:
        vendor:[]
        unique-thread:[vendor]
        above-vendor:[vendor]

        - unique-thread has work not in vendor and not in above-vendor.

        The returned loom is on the vendor thread.
        """
        tree, _ = self.get_two_thread_loom()
        tree.branch.new_thread('unique-thread', 'vendor')
        loom_tree = LoomTreeDecorator(tree)
        loom_tree.up_thread()
        self.build_tree(['file-b'])
        tree.add('file-b')
        tree.commit('a unique change', rev_id=b'uniquely-yrs-1')
        loom_tree.down_thread()
        return tree, loom_tree