Beispiel #1
0
    def launch_merge_tool(self):
        items = self.conflicts_list.selectedItems()
        enabled, error_msg = self.is_merge_tool_launchable()
        if not enabled:
            return
        config = GlobalConfig()
        cmdline = config.find_merge_tool(
            unicode(self.merge_tools_combo.currentText()))
        file_id = str(items[0].data(0, QtCore.Qt.UserRole).toString())
        if not file_id:
            # bug https://bugs.launchpad.net/qbzr/+bug/655451
            return
        file_name = self.wt.abspath(self.wt.id2path(file_id))
        process = QtCore.QProcess(self)

        def qprocess_invoker(executable, args, cleanup):
            def qprocess_error(error):
                self.show_merge_tool_error(error)
                cleanup(process.exitCode())

            def qprocess_finished(exit_code, exit_status):
                cleanup(exit_code)

            self.connect(process,
                         QtCore.SIGNAL("error(QProcess::ProcessError)"),
                         qprocess_error)
            self.connect(process,
                         QtCore.SIGNAL("finished(int,QProcess::ExitStatus)"),
                         qprocess_finished)
            process.start(executable, args)

        mergetools.invoke(cmdline, file_name, qprocess_invoker)
Beispiel #2
0
 def is_merge_tool_launchable(self):
     if mergetools is None:
         return False, gettext(
             "Bazaar 2.4 or later is required for external mergetools support"
         )
     items = self.conflicts_list.selectedItems()
     error_msg = ""
     enabled = True
     if len(items) != 1 or items[0].data(
             1, QtCore.Qt.UserRole).toString() != "text conflict":
         enabled = False
     config = GlobalConfig()
     tool = unicode(self.merge_tools_combo.currentText())
     cmdline = config.find_merge_tool(tool)
     if cmdline is None:
         error_msg = gettext(
             "Set up external_merge app in qconfig under the Merge tab")
         enabled = False
     elif not mergetools.check_availability(cmdline):
         enabled = False
         error_msg = gettext("External merge tool %(tool)s is not available") % \
                 { 'tool': tool }
     return enabled, error_msg