src/eric7/Plugins/VcsPlugins/vcsGit/GitStatusMonitorThread.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
--- a/src/eric7/Plugins/VcsPlugins/vcsGit/GitStatusMonitorThread.py	Wed Jul 13 11:16:20 2022 +0200
+++ b/src/eric7/Plugins/VcsPlugins/vcsGit/GitStatusMonitorThread.py	Wed Jul 13 14:55:47 2022 +0200
@@ -18,28 +18,29 @@
     """
     Class implementing the VCS status monitor thread class for Git.
     """
+
     ConflictStates = ["AA", "AU", "DD", "DU", "UA", "UD", "UU"]
-    
+
     def __init__(self, interval, project, vcs, parent=None):
         """
         Constructor
-        
+
         @param interval new interval in seconds (integer)
         @param project reference to the project object (Project)
         @param vcs reference to the version control object
         @param parent reference to the parent object (QObject)
         """
         VcsStatusMonitorThread.__init__(self, interval, project, vcs, parent)
-        
+
         self.__ioEncoding = Preferences.getSystem("IOEncoding")
-        
+
         self.__client = None
         self.__useCommandLine = False
-    
+
     def _performMonitor(self):
         """
         Protected method implementing the monitoring action.
-        
+
         This method populates the statusList member variable
         with a list of strings giving the status in the first column and the
         path relative to the project directory starting with the third column.
@@ -55,40 +56,42 @@
             <li>"!" path is missing</li>
             <li>" " path is back at normal</li>
         </ul>
-        
+
         @return tuple of flag indicating successful operation (boolean) and
             a status message in case of non successful operation (string)
         """
         self.shouldUpdate = False
-        
+
         # step 1: get overall status
         args = self.vcs.initCommand("status")
-        args.append('--porcelain')
-        
+        args.append("--porcelain")
+
         output = ""
         error = ""
         process = QProcess()
         process.setWorkingDirectory(self.projectDir)
-        process.start('git', args)
+        process.start("git", args)
         procStarted = process.waitForStarted(5000)
         if procStarted:
             finished = process.waitForFinished(300000)
             if finished and process.exitCode() == 0:
-                output = str(process.readAllStandardOutput(),
-                             self.__ioEncoding, 'replace')
+                output = str(
+                    process.readAllStandardOutput(), self.__ioEncoding, "replace"
+                )
             else:
                 process.kill()
                 process.waitForFinished()
-                error = str(process.readAllStandardError(),
-                            self.__ioEncoding, 'replace')
+                error = str(
+                    process.readAllStandardError(), self.__ioEncoding, "replace"
+                )
         else:
             process.kill()
             process.waitForFinished()
             error = self.tr("Could not start the Git process.")
-        
+
         if error:
             return False, error
-        
+
         states = {}
         for line in output.splitlines():
             flags = line[:2]
@@ -111,32 +114,28 @@
                 states[name] = status
             elif flags == "??":
                 states[name] = "?"
-        
+
         # step 2: collect the status to be reported back
         for name in states:
             try:
                 if self.reportedStates[name] != states[name]:
-                    self.statusList.append(
-                        "{0} {1}".format(states[name], name))
+                    self.statusList.append("{0} {1}".format(states[name], name))
             except KeyError:
                 self.statusList.append("{0} {1}".format(states[name], name))
         for name in self.reportedStates:
             if name not in states:
                 self.statusList.append("  {0}".format(name))
         self.reportedStates = states
-        
-        return (
-            True,
-            self.tr("Git status checked successfully")
-        )
-    
+
+        return (True, self.tr("Git status checked successfully"))
+
     def _getInfo(self):
         """
         Protected method implementing the real info action.
-        
+
         This method should be overridden and create a short info message to be
         shown in the main window status bar right next to the status indicator.
-        
+
         @return short info message
         @rtype str
         """
@@ -144,19 +143,21 @@
         args.append("--abbrev-commit")
         args.append("--format=%h %D")
         args.append("--no-patch")
-        
+
         output = ""
         process = QProcess()
         process.setWorkingDirectory(self.projectDir)
-        process.start('git', args)
+        process.start("git", args)
         procStarted = process.waitForStarted(5000)
         if procStarted:
             finished = process.waitForFinished(30000)
             if finished and process.exitCode() == 0:
-                output = str(process.readAllStandardOutput(),
-                             Preferences.getSystem("IOEncoding"),
-                             'replace')
-        
+                output = str(
+                    process.readAllStandardOutput(),
+                    Preferences.getSystem("IOEncoding"),
+                    "replace",
+                )
+
         if output:
             commitId, refs = output.splitlines()[0].strip().split(None, 1)
             ref = refs.split(",", 1)[0]
@@ -164,12 +165,11 @@
                 branch = ref.split("->", 1)[1].strip()
             else:
                 branch = self.tr("<detached>")
-        
-            return self.tr("{0} / {1}", "branch, commit").format(
-                branch, commitId)
+
+            return self.tr("{0} / {1}", "branch, commit").format(branch, commitId)
         else:
             return ""
-    
+
     def _shutdown(self):
         """
         Protected method performing shutdown actions.

eric ide

mercurial