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

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
--- a/src/eric7/Plugins/VcsPlugins/vcsMercurial/HgConflictsListDialog.py	Wed Jul 13 11:16:20 2022 +0200
+++ b/src/eric7/Plugins/VcsPlugins/vcsMercurial/HgConflictsListDialog.py	Wed Jul 13 14:55:47 2022 +0200
@@ -10,8 +10,12 @@
 
 from PyQt6.QtCore import pyqtSlot, Qt, QPoint
 from PyQt6.QtWidgets import (
-    QAbstractButton, QDialogButtonBox, QHeaderView, QTreeWidgetItem,
-    QApplication, QWidget
+    QAbstractButton,
+    QDialogButtonBox,
+    QHeaderView,
+    QTreeWidgetItem,
+    QApplication,
+    QWidget,
 )
 
 from EricWidgets.EricApplication import ericApp
@@ -26,87 +30,84 @@
     Class implementing a dialog to show a list of files which had or still
     have conflicts.
     """
+
     StatusRole = Qt.ItemDataRole.UserRole + 1
     FilenameRole = Qt.ItemDataRole.UserRole + 2
-    
+
     def __init__(self, vcs, parent=None):
         """
         Constructor
-        
+
         @param vcs reference to the vcs object
         @param parent parent widget (QWidget)
         """
         super().__init__(parent)
         self.setupUi(self)
-        
+
         self.__position = QPoint()
-        
-        self.buttonBox.button(
-            QDialogButtonBox.StandardButton.Close).setEnabled(False)
-        self.buttonBox.button(
-            QDialogButtonBox.StandardButton.Cancel).setDefault(True)
-        
-        self.conflictsList.headerItem().setText(
-            self.conflictsList.columnCount(), "")
-        self.conflictsList.header().setSortIndicator(
-            0, Qt.SortOrder.AscendingOrder)
-        
+
+        self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(False)
+        self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setDefault(True)
+
+        self.conflictsList.headerItem().setText(self.conflictsList.columnCount(), "")
+        self.conflictsList.header().setSortIndicator(0, Qt.SortOrder.AscendingOrder)
+
         self.refreshButton = self.buttonBox.addButton(
-            self.tr("&Refresh"), QDialogButtonBox.ButtonRole.ActionRole)
-        self.refreshButton.setToolTip(
-            self.tr("Press to refresh the list of conflicts"))
+            self.tr("&Refresh"), QDialogButtonBox.ButtonRole.ActionRole
+        )
+        self.refreshButton.setToolTip(self.tr("Press to refresh the list of conflicts"))
         self.refreshButton.setEnabled(False)
-        
+
         self.vcs = vcs
         self.project = ericApp().getObject("Project")
-        
+
         self.__hgClient = vcs.getClient()
-    
+
     def closeEvent(self, e):
         """
         Protected slot implementing a close event handler.
-        
+
         @param e close event (QCloseEvent)
         """
         if self.__hgClient.isExecuting():
             self.__hgClient.cancel()
-        
+
         self.__position = self.pos()
-        
+
         e.accept()
-    
+
     def show(self):
         """
         Public slot to show the dialog.
         """
         if not self.__position.isNull():
             self.move(self.__position)
-        
+
         super().show()
-    
+
     def start(self):
         """
         Public slot to start the tags command.
         """
         self.errorGroup.hide()
         QApplication.processEvents()
-            
+
         self.intercept = False
-        
+
         self.activateWindow()
         self.raise_()
-        
+
         self.conflictsList.clear()
         self.__started = True
         self.__getEntries()
-    
+
     def __getEntries(self):
         """
         Private method to get the conflict entries.
         """
         args = self.vcs.initCommand("resolve")
-        args.append('--list')
-        
+        args.append("--list")
+
         out, err = self.__hgClient.runcommand(args)
         if err:
             self.__showError(err)
@@ -122,57 +123,52 @@
         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).setEnabled(True)
+        self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setEnabled(False)
+        self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setDefault(True)
+
         self.refreshButton.setEnabled(True)
-        
+
         self.__resizeColumns()
         self.__resort()
         self.on_conflictsList_itemSelectionChanged()
-    
+
     @pyqtSlot(QAbstractButton)
     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.__hgClient.cancel()
         elif button == self.refreshButton:
             self.on_refreshButton_clicked()
-    
+
     def __resort(self):
         """
         Private method to resort the tree.
         """
         self.conflictsList.sortItems(
             self.conflictsList.sortColumn(),
-            self.conflictsList.header().sortIndicatorOrder())
-    
+            self.conflictsList.header().sortIndicatorOrder(),
+        )
+
     def __resizeColumns(self):
         """
         Private method to resize the list columns.
         """
         self.conflictsList.header().resizeSections(
-            QHeaderView.ResizeMode.ResizeToContents)
+            QHeaderView.ResizeMode.ResizeToContents
+        )
         self.conflictsList.header().setStretchLastSection(True)
-    
+
     def __generateItem(self, status, name):
         """
         Private method to generate a tag item in the tag list.
-        
+
         @param status status of the file (string)
         @param name name of the file (string)
         """
@@ -184,54 +180,51 @@
         else:
             itm.setText(0, self.tr("Unknown Status"))
         itm.setText(1, name)
-        
+
         itm.setData(0, self.StatusRole, status)
         itm.setData(0, self.FilenameRole, self.project.getAbsolutePath(name))
-    
+
     def __processOutputLine(self, line):
         """
         Private method to process the lines of output.
-        
+
         @param line output line to be processed (string)
         """
         status, filename = line.strip().split(None, 1)
         self.__generateItem(status, filename)
-    
+
     def __showError(self, out):
         """
         Private slot to show some error.
-        
+
         @param out error to be shown (string)
         """
         self.errorGroup.show()
         self.errors.insertPlainText(out)
         self.errors.ensureCursorVisible()
-    
+
     @pyqtSlot()
     def on_refreshButton_clicked(self):
         """
         Private slot to refresh the log.
         """
-        self.buttonBox.button(
-            QDialogButtonBox.StandardButton.Close).setEnabled(False)
-        self.buttonBox.button(
-            QDialogButtonBox.StandardButton.Cancel).setEnabled(True)
-        self.buttonBox.button(
-            QDialogButtonBox.StandardButton.Cancel).setDefault(True)
-        
+        self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(False)
+        self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setEnabled(True)
+        self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setDefault(True)
+
         self.refreshButton.setEnabled(False)
         self.start()
-    
+
     @pyqtSlot(QTreeWidgetItem, int)
     def on_conflictsList_itemDoubleClicked(self, item, column):
         """
         Private slot to open the double clicked entry.
-        
+
         @param item reference to the double clicked item (QTreeWidgetItem)
         @param column column that was double clicked (integer)
         """
         self.on_editButton_clicked()
-    
+
     @pyqtSlot()
     def on_conflictsList_itemSelectionChanged(self):
         """
@@ -245,16 +238,17 @@
                 unresolved += 1
             elif status == "R":
                 resolved += 1
-        
+
         self.resolvedButton.setEnabled(unresolved > 0)
         self.unresolvedButton.setEnabled(resolved > 0)
         self.reMergeButton.setEnabled(unresolved > 0)
         self.editButton.setEnabled(
-            selectedCount == 1 and
-            Utilities.MimeTypes.isTextFile(
-                self.conflictsList.selectedItems()[0].data(
-                    0, self.FilenameRole)))
-    
+            selectedCount == 1
+            and Utilities.MimeTypes.isTextFile(
+                self.conflictsList.selectedItems()[0].data(0, self.FilenameRole)
+            )
+        )
+
     @pyqtSlot()
     def on_resolvedButton_clicked(self):
         """
@@ -268,7 +262,7 @@
         if names:
             self.vcs.vcsResolved(names)
             self.on_refreshButton_clicked()
-    
+
     @pyqtSlot()
     def on_unresolvedButton_clicked(self):
         """
@@ -282,7 +276,7 @@
         if names:
             self.vcs.vcsResolved(names, unresolve=True)
             self.on_refreshButton_clicked()
-    
+
     @pyqtSlot()
     def on_reMergeButton_clicked(self):
         """
@@ -295,7 +289,7 @@
         ]
         if names:
             self.vcs.hgReMerge(names)
-    
+
     @pyqtSlot()
     def on_editButton_clicked(self):
         """

eric ide

mercurial