def test_get_button_bar_with_operations(self): window = DiffWindow() method = MockMethod() button_bar = window._get_button_bar([('title', method)]) self.assertIsNot(None, button_bar) buttons = button_bar.get_children() self.assertEqual(1, len(buttons)) self.assertEqual('title', buttons[0].props.label) buttons[0].emit('clicked') self.assertIs(True, method.called)
def show_diff(self, revid, parentid=NULL_REVISION): """Open a new window to show a diff between the given revisions.""" from bzrlib.plugins.gtk.diff import DiffWindow window = DiffWindow(parent=self) rev_tree = self.branch.repository.revision_tree(revid) parent_tree = self.branch.repository.revision_tree(parentid) description = revid + " - " + self.branch._get_nick(local=True) window.set_diff(description, rev_tree, parent_tree) window.show()
def show_diff(self, item): from bzrlib.plugins.gtk.diff import DiffWindow window = DiffWindow(parent=self._parent) parentids = self.repository.get_revision(self.revids[0]).parent_ids if len(parentids) == 0: parentid = NULL_REVISION else: parentid = parentids[0] rev_tree = self.repository.revision_tree(self.revids[0]) parent_tree = self.repository.revision_tree(parentid) window.set_diff(self.revids[0], rev_tree, parent_tree) window.show()
def test_get_menu_bar(self): window = DiffWindow() menu_bar = window._get_menu_bar() self.assertIsNot(None, menu_bar) menus = menu_bar.get_children() self.assertEqual(1, len(menus)) self.assertEqual('_View', menus[0].props.label) sub_menu = menus[0].get_submenu() self.assertIsNot(None, sub_menu) items = sub_menu.get_children() self.assertEqual(1, len(items)) menus[0].get_submenu().get_children()[0].props.label self.assertEqual('Wrap _Long Lines', items[0].props.label)
def diff_cb(self, menu, vfs_file): # We can only cope with local files if vfs_file.get_uri_scheme() != 'file': return file = vfs_file.get_uri() try: tree, path = WorkingTree.open_containing(file) except NotBranchError: return from bzrlib.plugins.gtk.diff import DiffWindow window = DiffWindow() window.set_diff(tree.branch._get_nick(local=True), tree, tree.branch.basis_tree()) window.show() return
def line_diff(self, tv, path, tvc): row = path[0] revision = self.annotations[row] repository = self.branch.repository if revision.revision_id == CURRENT_REVISION: tree1 = self.tree tree2 = self.tree.basis_tree() else: tree1 = repository.revision_tree(revision.revision_id) if len(revision.parent_ids) > 0: tree2 = repository.revision_tree(revision.parent_ids[0]) else: tree2 = repository.revision_tree(NULL_REVISION) from bzrlib.plugins.gtk.diff import DiffWindow window = DiffWindow(self) window.set_diff("Diff for line %d" % (row+1), tree1, tree2) window.set_file(tree1.id2path(self.file_id)) window.show()
def test_get_button_bar_with_none(self): window = DiffWindow() self.assertIs(None, window._get_button_bar(None))
def diff_cb(self, menu, tree, path=None): from bzrlib.plugins.gtk.diff import DiffWindow window = DiffWindow() window.set_diff(tree.branch._get_nick(local=True), tree, tree.branch.basis_tree()) window.show()