src/eric7/Plugins/VcsPlugins/vcsMercurial/HgDialog.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
diff -r e9e7eca7efee -r bf71ee032bb4 src/eric7/Plugins/VcsPlugins/vcsMercurial/HgDialog.py
--- a/src/eric7/Plugins/VcsPlugins/vcsMercurial/HgDialog.py	Wed Jul 13 11:16:20 2022 +0200
+++ b/src/eric7/Plugins/VcsPlugins/vcsMercurial/HgDialog.py	Wed Jul 13 14:55:47 2022 +0200
@@ -19,15 +19,16 @@
 class HgDialog(QDialog, Ui_HgDialog):
     """
     Class implementing a dialog starting a process and showing its output.
-    
+
     It starts a QProcess and displays a dialog that
     shows the output of the process. The dialog is modal,
     which causes a synchronized execution of the process.
     """
+
     def __init__(self, text, hg=None, useClient=True, parent=None):
         """
         Constructor
-        
+
         @param text text to be shown by the label (string)
         @param hg reference to the Mercurial interface object (Hg)
         @param useClient flag indicating to use the command server client
@@ -37,62 +38,53 @@
         super().__init__(parent)
         self.setupUi(self)
         self.setWindowFlags(Qt.WindowType.Window)
-        
-        self.buttonBox.button(
-            QDialogButtonBox.StandardButton.Close).setEnabled(False)
-        self.buttonBox.button(
-            QDialogButtonBox.StandardButton.Cancel).setDefault(True)
-        
-        self.username = ''
-        self.password = ''
+
+        self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(False)
+        self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setDefault(True)
+
+        self.username = ""
+        self.password = ""
         self.vcs = hg
-        
+
         self.outputGroup.setTitle(text)
-        
+
         self.show()
         QCoreApplication.processEvents()
-    
+
     def __finish(self):
         """
         Private slot called when the process finished or the user pressed
         the button.
         """
-        self.buttonBox.button(
-            QDialogButtonBox.StandardButton.Close).setEnabled(True)
-        self.buttonBox.button(
-            QDialogButtonBox.StandardButton.Cancel).setEnabled(False)
-        self.buttonBox.button(
-            QDialogButtonBox.StandardButton.Close).setDefault(True)
-        self.buttonBox.button(
-            QDialogButtonBox.StandardButton.Close).setFocus(
-                Qt.FocusReason.OtherFocusReason)
-        
+        self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(True)
+        self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setEnabled(False)
+        self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setDefault(True)
+        self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setFocus(
+            Qt.FocusReason.OtherFocusReason
+        )
+
         if (
-            Preferences.getVCS("AutoClose") and
-            self.normal and
-            self.errors.toPlainText() == ""
+            Preferences.getVCS("AutoClose")
+            and self.normal
+            and self.errors.toPlainText() == ""
         ):
             self.accept()
-    
+
     def on_buttonBox_clicked(self, button):
         """
         Private slot called by a button of the button box clicked.
-        
+
         @param button button that was clicked (QAbstractButton)
         """
-        if button == self.buttonBox.button(
-            QDialogButtonBox.StandardButton.Close
-        ):
+        if button == self.buttonBox.button(QDialogButtonBox.StandardButton.Close):
             self.close()
-        elif button == self.buttonBox.button(
-            QDialogButtonBox.StandardButton.Cancel
-        ):
+        elif button == self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel):
             self.vcs.getClient().cancel()
-    
+
     def startProcess(self, args, showArgs=True, environment=None, client=None):
         """
         Public slot used to start the process.
-        
+
         @param args list of arguments for the process
         @type list of str
         @param showArgs flag indicating to show the arguments
@@ -108,105 +100,112 @@
         self.errorGroup.hide()
         self.inputGroup.hide()
         self.normal = False
-        
+
         self.__hasAddOrDelete = False
-        if (
-            args[0] in ["qpush", "qpop", "qgoto", "rebase",
-                        "update", "import", "revert", "graft", "shelve",
-                        "unshelve", "strip", "histedit"] or
-            (args[0] in ["pull", "unbundle"] and
-             ("--update" in args[1:] or "--rebase" in args[1:]))
+        if args[0] in [
+            "qpush",
+            "qpop",
+            "qgoto",
+            "rebase",
+            "update",
+            "import",
+            "revert",
+            "graft",
+            "shelve",
+            "unshelve",
+            "strip",
+            "histedit",
+        ] or (
+            args[0] in ["pull", "unbundle"]
+            and ("--update" in args[1:] or "--rebase" in args[1:])
         ):
             self.__updateCommand = True
         else:
             self.__updateCommand = False
-        
+
         if showArgs:
-            self.resultbox.append(' '.join(args))
-            self.resultbox.append('')
-        
+            self.resultbox.append(" ".join(args))
+            self.resultbox.append("")
+
         if client is None:
             client = self.vcs.getClient()
         out, err = client.runcommand(
             args,
             prompt=self.__getInput,
             output=self.__showOutput,
-            error=self.__showError
+            error=self.__showError,
         )
-        
+
         if err:
             self.__showError(err)
         if out:
             self.__showOutput(out)
-        
+
         self.normal = True
-        
+
         self.__finish()
-        
+
         return True
-    
+
     def normalExit(self):
         """
         Public method to check for a normal process termination.
-        
+
         @return flag indicating normal process termination (boolean)
         """
         return self.normal
-    
+
     def normalExitWithoutErrors(self):
         """
         Public method to check for a normal process termination without
         error messages.
-        
+
         @return flag indicating normal process termination (boolean)
         """
         return self.normal and self.errors.toPlainText() == ""
-    
+
     def __showOutput(self, out):
         """
         Private slot to show some output.
-        
+
         @param out output to be shown (string)
         """
         self.resultbox.insertPlainText(Utilities.filterAnsiSequences(out))
         self.resultbox.ensureCursorVisible()
-        
+
         # check for a changed project file
         if self.__updateCommand:
             for line in out.splitlines():
-                if (
-                    '.epj' in line or
-                    '.e4p' in line
-                ):
+                if ".epj" in line or ".e4p" in line:
                     self.__hasAddOrDelete = True
                     break
-        
+
         QCoreApplication.processEvents()
-    
+
     def __showError(self, out):
         """
         Private slot to show some error.
-        
+
         @param out error to be shown (string)
         """
         self.errorGroup.show()
         self.errors.insertPlainText(Utilities.filterAnsiSequences(out))
         self.errors.ensureCursorVisible()
-        
+
         QCoreApplication.processEvents()
-    
+
     def hasAddOrDelete(self):
         """
         Public method to check, if the last action contained an add or delete.
-        
+
         @return flag indicating the presence of an add or delete (boolean)
         """
         return self.__hasAddOrDelete
-    
+
     def __getInput(self, size, message):
         """
         Private method to get some input from the user.
-        
+
         @param size maximum length of the requested input
         @type int
         @param message message sent by the server
@@ -221,16 +220,17 @@
 
         self.resultbox.ensureCursorVisible()
         self.errors.ensureCursorVisible()
-        
+
         from PyQt6.QtCore import QEventLoop
+
         loop = QEventLoop(self)
         self.sendButton.clicked[bool].connect(loop.quit)
         self.input.returnPressed.connect(loop.quit)
         loop.exec()
         message = self.input.text() + "\n"
         isPassword = self.passwordCheckBox.isChecked()
-        
+
         self.input.clear()
         self.inputGroup.hide()
-        
+
         return message, isPassword

eric ide

mercurial