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

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
diff -r e9e7eca7efee -r bf71ee032bb4 src/eric7/Plugins/VcsPlugins/vcsMercurial/HgAnnotateDialog.py
--- a/src/eric7/Plugins/VcsPlugins/vcsMercurial/HgAnnotateDialog.py	Wed Jul 13 11:16:20 2022 +0200
+++ b/src/eric7/Plugins/VcsPlugins/vcsMercurial/HgAnnotateDialog.py	Wed Jul 13 14:55:47 2022 +0200
@@ -10,9 +10,7 @@
 import re
 
 from PyQt6.QtCore import Qt, QCoreApplication
-from PyQt6.QtWidgets import (
-    QDialog, QDialogButtonBox, QHeaderView, QTreeWidgetItem
-)
+from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QHeaderView, QTreeWidgetItem
 
 from .Ui_HgAnnotateDialog import Ui_HgAnnotateDialog
 
@@ -23,51 +21,50 @@
     """
     Class implementing a dialog to show the output of the hg annotate command.
     """
+
     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.setWindowFlags(Qt.WindowType.Window)
-        
-        self.buttonBox.button(
-            QDialogButtonBox.StandardButton.Close).setEnabled(False)
-        self.buttonBox.button(
-            QDialogButtonBox.StandardButton.Cancel).setDefault(True)
-        
+
+        self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(False)
+        self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setDefault(True)
+
         self.vcs = vcs
         self.__hgClient = vcs.getClient()
-        
+
         self.__annotateRe = re.compile(
-            r"""(.+)\s+(\d+)\s+([0-9a-fA-F]+)\s+([0-9-]+)\s+(.+)""")
-        
-        self.annotateList.headerItem().setText(
-            self.annotateList.columnCount(), "")
+            r"""(.+)\s+(\d+)\s+([0-9a-fA-F]+)\s+([0-9-]+)\s+(.+)"""
+        )
+
+        self.annotateList.headerItem().setText(self.annotateList.columnCount(), "")
         font = Preferences.getEditorOtherFonts("MonospacedFont")
         self.annotateList.setFont(font)
-        
+
         self.show()
         QCoreApplication.processEvents()
-    
+
     def closeEvent(self, e):
         """
         Protected slot implementing a close event handler.
-        
+
         @param e close event (QCloseEvent)
         """
         if self.__hgClient.isExecuting():
             self.__hgClient.cancel()
-        
+
         e.accept()
-    
+
     def start(self, fn):
         """
         Public slot to start the annotate command.
-        
+
         @param fn filename to show the annotation for (string)
         """
         self.annotateList.clear()
@@ -75,16 +72,16 @@
         self.intercept = False
         self.activateWindow()
         self.lineno = 1
-        
+
         args = self.vcs.initCommand("annotate")
-        args.append('--follow')
-        args.append('--user')
-        args.append('--date')
-        args.append('--number')
-        args.append('--changeset')
-        args.append('--quiet')
+        args.append("--follow")
+        args.append("--user")
+        args.append("--date")
+        args.append("--number")
+        args.append("--changeset")
+        args.append("--quiet")
         args.append(fn)
-        
+
         out, err = self.__hgClient.runcommand(args)
         if err:
             self.__showError(err)
@@ -94,53 +91,47 @@
                 if self.__hgClient.wasCanceled():
                     break
         self.__finish()
-    
+
     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
+        )
+
         self.__resizeColumns()
-    
+
     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):
             if self.__hgClient:
                 self.__hgClient.cancel()
             else:
                 self.__finish()
-    
+
     def __resizeColumns(self):
         """
         Private method to resize the list columns.
         """
         self.annotateList.header().resizeSections(
-            QHeaderView.ResizeMode.ResizeToContents)
-    
+            QHeaderView.ResizeMode.ResizeToContents
+        )
+
     def __generateItem(self, revision, changeset, author, date, text):
         """
         Private method to generate an annotate item in the annotation list.
-        
+
         @param revision revision string (string)
         @param changeset changeset string (string)
         @param author author of the change (string)
@@ -149,16 +140,16 @@
         """
         itm = QTreeWidgetItem(
             self.annotateList,
-            [revision, changeset, author, date, "{0:d}".format(self.lineno),
-             text])
+            [revision, changeset, author, date, "{0:d}".format(self.lineno), text],
+        )
         self.lineno += 1
         itm.setTextAlignment(0, Qt.AlignmentFlag.AlignRight)
         itm.setTextAlignment(4, Qt.AlignmentFlag.AlignRight)
-    
+
     def __processOutputLine(self, line):
         """
         Private method to process the lines of output.
-        
+
         @param line output line to be processed (string)
         """
         try:
@@ -168,13 +159,14 @@
             text = ""
         match = self.__annotateRe.match(info)
         author, rev, changeset, date, file = match.groups()
-        self.__generateItem(rev.strip(), changeset.strip(), author.strip(),
-                            date.strip(), text)
-    
+        self.__generateItem(
+            rev.strip(), changeset.strip(), author.strip(), date.strip(), text
+        )
+
     def __showError(self, out):
         """
         Private slot to show some error.
-        
+
         @param out error to be shown (string)
         """
         self.errorGroup.show()

eric ide

mercurial