def test_up_not_merged(self): """up-thread from a thread with new work.""" tree = self.get_tree_with_loom('tree') tree.branch.new_thread('bottom') tree.branch._set_nick('bottom') bottom_rev1 = tree.commit('bottom_commit') tree.branch.new_thread('top', 'bottom') tree.branch._set_nick('top') top_rev1 = tree.commit('top_commit', allow_pointless=True) tree_loom_tree = breezy.plugins.loom.tree.LoomTreeDecorator(tree) tree_loom_tree.down_thread() # check the test will be valid tree.lock_read() try: graph = tree.branch.repository.get_graph() self.assertEqual( [top_rev1, bottom_rev1, NULL_REVISION], [r for (r, ps) in graph.iter_ancestry([top_rev1])]) self.assertEqual([bottom_rev1], tree.get_parent_ids()) finally: tree.unlock() bottom_rev2 = tree.commit('bottom_two', allow_pointless=True) tree_loom_tree.up_thread() self.assertEqual('top', tree.branch.nick) self.assertEqual([top_rev1, bottom_rev2], tree.get_parent_ids())
def test_revert_loom(self): tree = self.get_tree_with_loom(',') # ensure we have some stuff to revert tree.branch.new_thread('foo') tree.branch.new_thread('bar') tree.branch._set_nick('bar') tree.commit('change something', allow_pointless=True) loom_tree = breezy.plugins.loom.tree.LoomTreeDecorator(tree) loom_tree.revert_loom() # the tree should be reverted self.assertEqual(NULL_REVISION, tree.last_revision()) # the current loom should be reverted # (we assume this means branch.revert_loom was called()) self.assertEqual([], tree.branch.get_loom_state().get_threads())
def test_up_to_no_commits(self): tree = self.get_tree_with_loom('tree') tree.branch.new_thread('bottom') tree.branch.new_thread('top') tree.branch._set_nick('bottom') bottom_rev1 = tree.commit('bottom_commit') tree_loom_tree = breezy.plugins.loom.tree.LoomTreeDecorator(tree) tree_loom_tree.up_thread() self.assertEqual('top', tree.branch.nick) self.assertEqual([bottom_rev1], tree.get_parent_ids())
def test_up_many_halts_on_conflicts(self): loom_tree = self.get_loom_with_three_threads() tree = loom_tree.tree self.build_tree_contents([('source/file', 'contents-a')]) tree.add('file') tree.commit('bottom', rev_id=b'bottom-1') loom_tree.up_thread() self.build_tree_contents([('source/file', 'contents-b')]) tree.commit('middle', rev_id=b'middle-1') loom_tree.down_thread() self.build_tree_contents([('source/file', 'contents-c')]) tree.commit('bottom', rev_id=b'bottom-2') loom_tree.up_many() self.assertEqual('middle', tree.branch.nick) self.assertEqual([b'middle-1', b'bottom-2'], tree.get_parent_ids()) self.assertEqual(1, len(tree.conflicts()))
def _add_thread(self, tree, name): """Create a new thread with a commit and return the commit id.""" tree.branch.new_thread(name) tree.branch._set_nick(name) return tree.commit(name)