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

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9288
ce20d7c936b1
diff -r e9e7eca7efee -r bf71ee032bb4 src/eric7/Plugins/VcsPlugins/vcsMercurial/HgUtilities.py
--- a/src/eric7/Plugins/VcsPlugins/vcsMercurial/HgUtilities.py	Wed Jul 13 11:16:20 2022 +0200
+++ b/src/eric7/Plugins/VcsPlugins/vcsMercurial/HgUtilities.py	Wed Jul 13 14:55:47 2022 +0200
@@ -20,12 +20,12 @@
 def getHgExecutable():
     """
     Function to get the full path of the Mercurial executable.
-    
+
     @return path of the Mercurial executable
     @rtype str
     """
     from Plugins.PluginVcsMercurial import VcsMercurialPlugin
-    
+
     exe = VcsMercurialPlugin.getPreferences("MercurialExecutablePath")
     if not exe:
         program = "hg"
@@ -40,17 +40,17 @@
             dirName = os.path.dirname(sys.executable)
             if os.path.exists(os.path.join(dirName, program)):
                 exe = os.path.join(dirName, program)
-    
+
     if not exe:
         exe = program
-    
+
     return exe
 
 
 def getConfigPath():
     """
     Function to get the filename of the config file.
-    
+
     @return filename of the config file
     @rtype str
     """
@@ -65,7 +65,7 @@
 def prepareProcess(proc, encoding="", language=""):
     """
     Function to prepare the given process.
-    
+
     @param proc reference to the process to be prepared
     @type QProcess
     @param encoding encoding to be used by the process
@@ -74,23 +74,23 @@
     @type str
     """
     env = QProcessEnvironment.systemEnvironment()
-    env.insert("HGPLAIN", '1')
-    
+    env.insert("HGPLAIN", "1")
+
     # set the encoding for the process
     if encoding:
         env.insert("HGENCODING", encoding)
-    
+
     # set the language for the process
     if language:
         env.insert("LANGUAGE", language)
-    
+
     proc.setProcessEnvironment(env)
 
 
 def hgVersion(plugin):
     """
     Public method to determine the Mercurial version.
-    
+
     @param plugin reference to the plugin object
     @type VcsMercurialPlugin
     @return tuple containing the Mercurial version as a string and as a tuple
@@ -100,9 +100,9 @@
     versionStr = ""
     version = ()
     errorMsg = ""
-    
+
     exe = getHgExecutable()
-    
+
     args = ["version"]
     args.extend(plugin.getGlobalOptions())
     process = QProcess()
@@ -111,11 +111,17 @@
     if procStarted:
         finished = process.waitForFinished(30000)
         if finished and process.exitCode() == 0:
-            output = str(process.readAllStandardOutput(),
-                         plugin.getPreferences("Encoding"), 'replace')
+            output = str(
+                process.readAllStandardOutput(),
+                plugin.getPreferences("Encoding"),
+                "replace",
+            )
             versionStr = output.splitlines()[0].split()[-1][0:-1]
-            v = list(re.match(r'.*?(\d+)\.(\d+)\.?(\d+)?(\+[0-9a-f-]+)?',
-                              versionStr).groups())
+            v = list(
+                re.match(
+                    r".*?(\d+)\.(\d+)\.?(\d+)?(\+[0-9a-f-]+)?", versionStr
+                ).groups()
+            )
             if v[-1] is None:
                 del v[-1]
             for i in range(3):
@@ -129,16 +135,15 @@
         else:
             if finished:
                 errorMsg = QCoreApplication.translate(
-                    "HgUtilities",
-                    "The hg process finished with the exit code {0}"
+                    "HgUtilities", "The hg process finished with the exit code {0}"
                 ).format(process.exitCode())
             else:
                 errorMsg = QCoreApplication.translate(
-                    "HgUtilities",
-                    "The hg process did not finish within 30s.")
+                    "HgUtilities", "The hg process did not finish within 30s."
+                )
     else:
         errorMsg = QCoreApplication.translate(
-            "HgUtilities",
-            "Could not start the hg executable.")
-    
+            "HgUtilities", "Could not start the hg executable."
+        )
+
     return versionStr, version, errorMsg

eric ide

mercurial