5 |
5 |
6 """ |
6 """ |
7 Module implementing the Mercurial configuration page. |
7 Module implementing the Mercurial configuration page. |
8 """ |
8 """ |
9 |
9 |
|
10 import os |
|
11 import sys |
|
12 |
10 from PyQt6.QtCore import pyqtSlot |
13 from PyQt6.QtCore import pyqtSlot |
|
14 |
|
15 from EricWidgets.EricApplication import ericApp |
11 |
16 |
12 from Preferences.ConfigurationPages.ConfigurationPageBase import ( |
17 from Preferences.ConfigurationPages.ConfigurationPageBase import ( |
13 ConfigurationPageBase |
18 ConfigurationPageBase |
14 ) |
19 ) |
15 from .Ui_MercurialPage import Ui_MercurialPage |
20 from .Ui_MercurialPage import Ui_MercurialPage |
|
21 from .. import HgUtilities |
16 |
22 |
17 from Utilities import supportedCodecs |
23 from Utilities import supportedCodecs |
18 |
24 |
19 |
25 |
20 class MercurialPage(ConfigurationPageBase, Ui_MercurialPage): |
26 class MercurialPage(ConfigurationPageBase, Ui_MercurialPage): |
33 |
39 |
34 self.__plugin = plugin |
40 self.__plugin = plugin |
35 |
41 |
36 self.encodingComboBox.addItems(sorted(supportedCodecs)) |
42 self.encodingComboBox.addItems(sorted(supportedCodecs)) |
37 self.encodingModeComboBox.addItems(["strict", "ignore", "replace"]) |
43 self.encodingModeComboBox.addItems(["strict", "ignore", "replace"]) |
|
44 |
|
45 self.installButton.setEnabled(not self.__mercurialInstalled()) |
38 |
46 |
39 # set initial values |
47 # set initial values |
40 # global options |
48 # global options |
41 index = self.encodingComboBox.findText( |
49 index = self.encodingComboBox.findText( |
42 self.__plugin.getPreferences("Encoding")) |
50 self.__plugin.getPreferences("Encoding")) |
119 from ..HgUserConfigDialog import HgUserConfigDialog |
127 from ..HgUserConfigDialog import HgUserConfigDialog |
120 from ..HgUtilities import hgVersion |
128 from ..HgUtilities import hgVersion |
121 |
129 |
122 dlg = HgUserConfigDialog(version=hgVersion(self.__plugin)[1]) |
130 dlg = HgUserConfigDialog(version=hgVersion(self.__plugin)[1]) |
123 dlg.exec() |
131 dlg.exec() |
|
132 |
|
133 @pyqtSlot() |
|
134 def on_installButton_clicked(self): |
|
135 """ |
|
136 Private slot to install Mercurial alongside eric7. |
|
137 """ |
|
138 pip = ericApp().getObject("Pip") |
|
139 pip.installPackages(["mercurial"], interpreter=sys.executable) |
|
140 self.installButton.setEnabled(not self.__mercurialInstalled()) |
|
141 |
|
142 def __mercurialInstalled(self): |
|
143 """ |
|
144 Private method to check, if mercurial is installed alongside eric7. |
|
145 """ |
|
146 hg = HgUtilities.getHgExecutable() |
|
147 # assume local installation, if the path is absolute |
|
148 return os.path.isabs(hg) |