Made Mercurial an optional installation requirement.

Tue, 04 May 2021 19:30:25 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 04 May 2021 19:30:25 +0200
changeset 8288
809d5d5ac2ba
parent 8287
30eb7bc13d63
child 8289
871b40c5a77a

Made Mercurial an optional installation requirement.

eric6/APIs/Python3/eric6.api file | annotate | diff | comparison | revisions
eric6/Documentation/Source/eric6.Plugins.VcsPlugins.vcsMercurial.HgUtilities.html file | annotate | diff | comparison | revisions
eric6/Plugins/PluginVcsMercurial.py file | annotate | diff | comparison | revisions
eric6/Plugins/VcsPlugins/vcsMercurial/HgClient.py file | annotate | diff | comparison | revisions
eric6/Plugins/VcsPlugins/vcsMercurial/HgServeDialog.py file | annotate | diff | comparison | revisions
eric6/Plugins/VcsPlugins/vcsMercurial/HgUtilities.py file | annotate | diff | comparison | revisions
scripts/install.py file | annotate | diff | comparison | revisions
setup.py file | annotate | diff | comparison | revisions
--- a/eric6/APIs/Python3/eric6.api	Mon May 03 19:58:28 2021 +0200
+++ b/eric6/APIs/Python3/eric6.api	Tue May 04 19:30:25 2021 +0200
@@ -5330,6 +5330,7 @@
 eric6.Plugins.VcsPlugins.vcsMercurial.HgUserConfigHostMinimumProtocolDialog.HgUserConfigHostMinimumProtocolDialog.on_minimumProtocolComboBox_currentIndexChanged?4(index)
 eric6.Plugins.VcsPlugins.vcsMercurial.HgUserConfigHostMinimumProtocolDialog.HgUserConfigHostMinimumProtocolDialog?1(allowedProtocols, parent=None, host="", protocol="")
 eric6.Plugins.VcsPlugins.vcsMercurial.HgUtilities.getConfigPath?4()
+eric6.Plugins.VcsPlugins.vcsMercurial.HgUtilities.getHgExecutable?4()
 eric6.Plugins.VcsPlugins.vcsMercurial.HgUtilities.hgVersion?4(plugin)
 eric6.Plugins.VcsPlugins.vcsMercurial.HgUtilities.prepareProcess?4(proc, encoding="", language="")
 eric6.Plugins.VcsPlugins.vcsMercurial.HisteditExtension.HgHisteditCommitEditor.HgHisteditCommitEditor.on_buttonBox_accepted?4()
--- a/eric6/Documentation/Source/eric6.Plugins.VcsPlugins.vcsMercurial.HgUtilities.html	Mon May 03 19:58:28 2021 +0200
+++ b/eric6/Documentation/Source/eric6.Plugins.VcsPlugins.vcsMercurial.HgUtilities.html	Tue May 04 19:30:25 2021 +0200
@@ -41,7 +41,11 @@
 
 <tr>
 <td><a href="#getConfigPath">getConfigPath</a></td>
-<td>Public function to get the filename of the config file.</td>
+<td>Function to get the filename of the config file.</td>
+</tr>
+<tr>
+<td><a href="#getHgExecutable">getHgExecutable</a></td>
+<td>Function to get the full path of the Mercurial executable.</td>
 </tr>
 <tr>
 <td><a href="#hgVersion">hgVersion</a></td>
@@ -49,7 +53,7 @@
 </tr>
 <tr>
 <td><a href="#prepareProcess">prepareProcess</a></td>
-<td>Public function to prepare the given process.</td>
+<td>Function to prepare the given process.</td>
 </tr>
 </table>
 <hr />
@@ -59,12 +63,40 @@
 <b>getConfigPath</b>(<i></i>)
 
 <p>
-    Public function to get the filename of the config file.
+    Function to get the filename of the config file.
 </p>
 <dl>
 <dt>Return:</dt>
 <dd>
-filename of the config file (string)
+filename of the config file
+</dd>
+</dl>
+<dl>
+<dt>Return Type:</dt>
+<dd>
+str
+</dd>
+</dl>
+<div align="right"><a href="#top">Up</a></div>
+<hr />
+<hr />
+<a NAME="getHgExecutable" ID="getHgExecutable"></a>
+<h2>getHgExecutable</h2>
+<b>getHgExecutable</b>(<i></i>)
+
+<p>
+    Function to get the full path of the Mercurial executable.
+</p>
+<dl>
+<dt>Return:</dt>
+<dd>
+path of the Mercurial executable
+</dd>
+</dl>
+<dl>
+<dt>Return Type:</dt>
+<dd>
+str
 </dd>
 </dl>
 <div align="right"><a href="#top">Up</a></div>
@@ -105,21 +137,21 @@
 <b>prepareProcess</b>(<i>proc, encoding="", language=""</i>)
 
 <p>
-    Public function to prepare the given process.
+    Function to prepare the given process.
 </p>
 <dl>
 
-<dt><i>proc</i></dt>
+<dt><i>proc</i> (QProcess)</dt>
 <dd>
-reference to the process to be prepared (QProcess)
+reference to the process to be prepared
 </dd>
-<dt><i>encoding</i></dt>
+<dt><i>encoding</i> (str)</dt>
 <dd>
-encoding to be used by the process (string)
+encoding to be used by the process
 </dd>
-<dt><i>language</i></dt>
+<dt><i>language</i> (str)</dt>
 <dd>
-language to be set (string)
+language to be set
 </dd>
 </dl>
 <div align="right"><a href="#top">Up</a></div>
--- a/eric6/Plugins/PluginVcsMercurial.py	Mon May 03 19:58:28 2021 +0200
+++ b/eric6/Plugins/PluginVcsMercurial.py	Tue May 04 19:30:25 2021 +0200
@@ -17,7 +17,7 @@
 import Preferences
 from Preferences.Shortcuts import readShortcuts
 
-from VcsPlugins.vcsMercurial.HgUtilities import getConfigPath
+from VcsPlugins.vcsMercurial.HgUtilities import getConfigPath, getHgExecutable
 
 import Utilities
 import UI.Info
@@ -49,15 +49,11 @@
     @return dictionary containing the data to query the presence of
         the executable
     """
-    exe = 'hg'
-    if Utilities.isWindowsPlatform():
-        exe += '.exe'
-    
     data = {
         "programEntry": True,
         "header": QCoreApplication.translate(
             "VcsMercurialPlugin", "Version Control - Mercurial"),
-        "exe": exe,
+        "exe": getHgExecutable(),
         "versionCommand": 'version',
         "versionStartsWith": 'Mercurial',
         "versionPosition": -1,
@@ -77,9 +73,7 @@
     """
     global pluginTypename
     data = {}
-    exe = 'hg'
-    if Utilities.isWindowsPlatform():
-        exe += '.exe'
+    exe = getHgExecutable()
     if Utilities.isinpath(exe):
         data[".hg"] = (pluginTypename, displayString())
         data["_hg"] = (pluginTypename, displayString())
@@ -92,9 +86,7 @@
     
     @return display string (string)
     """
-    exe = 'hg'
-    if Utilities.isWindowsPlatform():
-        exe += '.exe'
+    exe = getHgExecutable()
     if Utilities.isinpath(exe):
         return QCoreApplication.translate('VcsMercurialPlugin', 'Mercurial')
     else:
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgClient.py	Mon May 03 19:58:28 2021 +0200
+++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgClient.py	Tue May 04 19:30:25 2021 +0200
@@ -15,7 +15,7 @@
 )
 from PyQt5.QtWidgets import QDialog
 
-from .HgUtilities import prepareProcess
+from .HgUtilities import prepareProcess, getHgExecutable
 
 
 class HgClient(QObject):
@@ -85,13 +85,14 @@
         
         prepareProcess(self.__server, self.__encoding)
         
-        self.__server.start('hg', self.__serverArgs)
+        exe = getHgExecutable()
+        self.__server.start(exe, self.__serverArgs)
         serverStarted = self.__server.waitForStarted(15000)
         if not serverStarted:
             return False, self.tr(
                 'The process {0} could not be started. '
                 'Ensure, that it is in the search path.'
-            ).format('hg')
+            ).format(exe)
         
         self.__server.setReadChannel(QProcess.ProcessChannel.StandardOutput)
         ok, error = self.__readHello()
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgServeDialog.py	Mon May 03 19:58:28 2021 +0200
+++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgServeDialog.py	Tue May 04 19:30:25 2021 +0200
@@ -20,8 +20,9 @@
 from E5Gui.E5MainWindow import E5MainWindow
 
 import UI.PixmapCache
+import Preferences
 
-import Preferences
+from .HgUtilities import getHgExecutable
 
 
 class HgServeDialog(E5MainWindow):
@@ -121,6 +122,8 @@
         port = self.__portSpin.value()
         style = self.__styleCombo.currentText()
         
+        exe = getHgExecutable()
+        
         args = self.vcs.initCommand("serve")
         args.append("-v")
         args.append("--port")
@@ -130,7 +133,7 @@
         
         self.process.setWorkingDirectory(self.__repoPath)
         
-        self.process.start('hg', args)
+        self.process.start(exe, args)
         procStarted = self.process.waitForStarted(5000)
         if procStarted:
             self.__startAct.setEnabled(False)
@@ -147,7 +150,7 @@
                 self.tr(
                     'The process {0} could not be started. '
                     'Ensure, that it is in the search path.'
-                ).format('hg'))
+                ).format(exe))
     
     def __stopServer(self):
         """
--- 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)
--- a/scripts/install.py	Mon May 03 19:58:28 2021 +0200
+++ b/scripts/install.py	Tue May 04 19:30:25 2021 +0200
@@ -1360,7 +1360,9 @@
         answer = input()                            # secok
     if answer in ("", "Y", "y"):
         exitCode = subprocess.call(                 # secok
-            [sys.executable, "-m", "pip", "install", packageName])
+            [sys.executable, "-m", "pip", "install", "--prefer-binary",
+             "--upgrade", packageName]
+        )
         ok = (exitCode == 0)
     
     return ok
@@ -1542,6 +1544,7 @@
         "EditorConfig": ("editorconfig", ""),
         "Send2Trash": ("send2trash", ""),
         "Pygments": ("pygments", ""),
+        "mercurial": ("mercurial", ""),
     }
     # dict with tuples of package name and install constraint
     if sys.platform != "darwin" and not ignorePyqt5Tools:
--- a/setup.py	Mon May 03 19:58:28 2021 +0200
+++ b/setup.py	Tue May 04 19:30:25 2021 +0200
@@ -349,6 +349,7 @@
         "EditorConfig",
         "Send2Trash",
         "Pygments",
+        "mercurial",
         "pywin32>=1.0;platform_system=='Windows'",
     ],
     data_files=getDataFiles(),

eric ide

mercurial