--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgUtilities.py Mon May 03 19:58:28 2021 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgUtilities.py Tue May 04 19:30:25 2021 +0200 @@ -9,17 +9,47 @@ import os import re +import sys from PyQt5.QtCore import QProcess, QProcessEnvironment, QCoreApplication import Utilities +from Globals import isWindowsPlatform + + +def getHgExecutable(): + """ + Function to get the full path of the Mercurial executable. + + @return path of the Mercurial executable + @rtype str + """ + exe = "" + program = "hg" + if isWindowsPlatform(): + program += ".exe" + dirName = os.path.dirname(sys.executable) + if os.path.exists(os.path.join(dirName, program)): + exe = os.path.join(dirName, program) + elif os.path.exists(os.path.join(dirName, "Scripts", program)): + exe = os.path.join(dirName, "Scripts", program) + else: + 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(): """ - Public function to get the filename of the config file. + Function to get the filename of the config file. - @return filename of the config file (string) + @return filename of the config file + @rtype str """ if Utilities.isWindowsPlatform(): userprofile = os.environ["USERPROFILE"] @@ -31,11 +61,14 @@ def prepareProcess(proc, encoding="", language=""): """ - Public function to prepare the given process. + Function to prepare the given process. - @param proc reference to the process to be prepared (QProcess) - @param encoding encoding to be used by the process (string) - @param language language to be set (string) + @param proc reference to the process to be prepared + @type QProcess + @param encoding encoding to be used by the process + @type str + @param language language to be set + @type str """ env = QProcessEnvironment.systemEnvironment() env.insert("HGPLAIN", '1') @@ -65,10 +98,12 @@ version = () errorMsg = "" + exe = getHgExecutable() + args = ["version"] args.extend(plugin.getGlobalOptions()) process = QProcess() - process.start('hg', args) + process.start(exe, args) procStarted = process.waitForStarted(5000) if procStarted: finished = process.waitForFinished(30000)