src/eric7/Plugins/VcsPlugins/vcsMercurial/ConfigurationPage/MercurialPage.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
12 from PyQt6.QtCore import pyqtSlot 12 from PyQt6.QtCore import pyqtSlot
13 13
14 from EricWidgets.EricApplication import ericApp 14 from EricWidgets.EricApplication import ericApp
15 from EricWidgets.EricPathPicker import EricPathPickerModes 15 from EricWidgets.EricPathPicker import EricPathPickerModes
16 16
17 from Preferences.ConfigurationPages.ConfigurationPageBase import ( 17 from Preferences.ConfigurationPages.ConfigurationPageBase import ConfigurationPageBase
18 ConfigurationPageBase
19 )
20 from .Ui_MercurialPage import Ui_MercurialPage 18 from .Ui_MercurialPage import Ui_MercurialPage
21 from .. import HgUtilities 19 from .. import HgUtilities
22 20
23 import Globals 21 import Globals
24 from Utilities import supportedCodecs 22 from Utilities import supportedCodecs
26 24
27 class MercurialPage(ConfigurationPageBase, Ui_MercurialPage): 25 class MercurialPage(ConfigurationPageBase, Ui_MercurialPage):
28 """ 26 """
29 Class implementing the Mercurial configuration page. 27 Class implementing the Mercurial configuration page.
30 """ 28 """
29
31 def __init__(self, plugin): 30 def __init__(self, plugin):
32 """ 31 """
33 Constructor 32 Constructor
34 33
35 @param plugin reference to the plugin object 34 @param plugin reference to the plugin object
36 """ 35 """
37 super().__init__() 36 super().__init__()
38 self.setupUi(self) 37 self.setupUi(self)
39 self.setObjectName("MercurialPage") 38 self.setObjectName("MercurialPage")
40 39
41 self.__plugin = plugin 40 self.__plugin = plugin
42 41
43 self.hgPicker.setMode(EricPathPickerModes.OPEN_FILE_MODE) 42 self.hgPicker.setMode(EricPathPickerModes.OPEN_FILE_MODE)
44 if Globals.isWindowsPlatform(): 43 if Globals.isWindowsPlatform():
45 self.hgPicker.setFilters(self.tr( 44 self.hgPicker.setFilters(
46 "Executable Files (*.exe);;" 45 self.tr("Executable Files (*.exe);;" "All Files (*)")
47 "All Files (*)" 46 )
48 ))
49 else: 47 else:
50 self.hgPicker.setFilters(self.tr("All Files (*)")) 48 self.hgPicker.setFilters(self.tr("All Files (*)"))
51 49
52 self.encodingComboBox.addItems(sorted(supportedCodecs)) 50 self.encodingComboBox.addItems(sorted(supportedCodecs))
53 self.encodingModeComboBox.addItems(["strict", "ignore", "replace"]) 51 self.encodingModeComboBox.addItems(["strict", "ignore", "replace"])
54 52
55 self.installButton.setEnabled(not self.__mercurialInstalled()) 53 self.installButton.setEnabled(not self.__mercurialInstalled())
56 54
57 # set initial values 55 # set initial values
58 # executable override 56 # executable override
59 self.hgPicker.setText( 57 self.hgPicker.setText(self.__plugin.getPreferences("MercurialExecutablePath"))
60 self.__plugin.getPreferences("MercurialExecutablePath")) 58
61
62 # global options 59 # global options
63 index = self.encodingComboBox.findText( 60 index = self.encodingComboBox.findText(self.__plugin.getPreferences("Encoding"))
64 self.__plugin.getPreferences("Encoding"))
65 self.encodingComboBox.setCurrentIndex(index) 61 self.encodingComboBox.setCurrentIndex(index)
66 index = self.encodingModeComboBox.findText( 62 index = self.encodingModeComboBox.findText(
67 self.__plugin.getPreferences("EncodingMode")) 63 self.__plugin.getPreferences("EncodingMode")
64 )
68 self.encodingModeComboBox.setCurrentIndex(index) 65 self.encodingModeComboBox.setCurrentIndex(index)
69 self.hiddenChangesetsCheckBox.setChecked( 66 self.hiddenChangesetsCheckBox.setChecked(
70 self.__plugin.getPreferences("ConsiderHidden")) 67 self.__plugin.getPreferences("ConsiderHidden")
68 )
71 # log 69 # log
72 self.logSpinBox.setValue( 70 self.logSpinBox.setValue(self.__plugin.getPreferences("LogLimit"))
73 self.__plugin.getPreferences("LogLimit"))
74 self.logWidthSpinBox.setValue( 71 self.logWidthSpinBox.setValue(
75 self.__plugin.getPreferences("LogMessageColumnWidth")) 72 self.__plugin.getPreferences("LogMessageColumnWidth")
73 )
76 self.startFullLogCheckBox.setChecked( 74 self.startFullLogCheckBox.setChecked(
77 self.__plugin.getPreferences("LogBrowserShowFullLog")) 75 self.__plugin.getPreferences("LogBrowserShowFullLog")
76 )
78 # commit 77 # commit
79 self.commitAuthorsSpinBox.setValue( 78 self.commitAuthorsSpinBox.setValue(
80 self.__plugin.getPreferences("CommitAuthorsLimit")) 79 self.__plugin.getPreferences("CommitAuthorsLimit")
80 )
81 # pull 81 # pull
82 self.pullUpdateCheckBox.setChecked( 82 self.pullUpdateCheckBox.setChecked(self.__plugin.getPreferences("PullUpdate"))
83 self.__plugin.getPreferences("PullUpdate"))
84 self.preferUnbundleCheckBox.setChecked( 83 self.preferUnbundleCheckBox.setChecked(
85 self.__plugin.getPreferences("PreferUnbundle")) 84 self.__plugin.getPreferences("PreferUnbundle")
85 )
86 # cleanup 86 # cleanup
87 self.cleanupPatternEdit.setText( 87 self.cleanupPatternEdit.setText(self.__plugin.getPreferences("CleanupPatterns"))
88 self.__plugin.getPreferences("CleanupPatterns"))
89 # revert 88 # revert
90 self.backupCheckBox.setChecked( 89 self.backupCheckBox.setChecked(self.__plugin.getPreferences("CreateBackup"))
91 self.__plugin.getPreferences("CreateBackup"))
92 # merge 90 # merge
93 self.internalMergeCheckBox.setChecked( 91 self.internalMergeCheckBox.setChecked(
94 self.__plugin.getPreferences("InternalMerge")) 92 self.__plugin.getPreferences("InternalMerge")
95 93 )
94
96 def save(self): 95 def save(self):
97 """ 96 """
98 Public slot to save the Mercurial configuration. 97 Public slot to save the Mercurial configuration.
99 """ 98 """
100 # executable override 99 # executable override
100 self.__plugin.setPreferences("MercurialExecutablePath", self.hgPicker.text())
101 # global options
102 self.__plugin.setPreferences("Encoding", self.encodingComboBox.currentText())
101 self.__plugin.setPreferences( 103 self.__plugin.setPreferences(
102 "MercurialExecutablePath", self.hgPicker.text()) 104 "EncodingMode", self.encodingModeComboBox.currentText()
103 # global options 105 )
104 self.__plugin.setPreferences( 106 self.__plugin.setPreferences(
105 "Encoding", self.encodingComboBox.currentText()) 107 "ConsiderHidden", self.hiddenChangesetsCheckBox.isChecked()
108 )
109 # log
110 self.__plugin.setPreferences("LogLimit", self.logSpinBox.value())
106 self.__plugin.setPreferences( 111 self.__plugin.setPreferences(
107 "EncodingMode", self.encodingModeComboBox.currentText()) 112 "LogMessageColumnWidth", self.logWidthSpinBox.value()
113 )
108 self.__plugin.setPreferences( 114 self.__plugin.setPreferences(
109 "ConsiderHidden", self.hiddenChangesetsCheckBox.isChecked()) 115 "LogBrowserShowFullLog", self.startFullLogCheckBox.isChecked()
110 # log 116 )
111 self.__plugin.setPreferences(
112 "LogLimit", self.logSpinBox.value())
113 self.__plugin.setPreferences(
114 "LogMessageColumnWidth", self.logWidthSpinBox.value())
115 self.__plugin.setPreferences(
116 "LogBrowserShowFullLog", self.startFullLogCheckBox.isChecked())
117 # commit 117 # commit
118 self.__plugin.setPreferences( 118 self.__plugin.setPreferences(
119 "CommitAuthorsLimit", self.commitAuthorsSpinBox.value()) 119 "CommitAuthorsLimit", self.commitAuthorsSpinBox.value()
120 )
120 # pull 121 # pull
122 self.__plugin.setPreferences("PullUpdate", self.pullUpdateCheckBox.isChecked())
121 self.__plugin.setPreferences( 123 self.__plugin.setPreferences(
122 "PullUpdate", self.pullUpdateCheckBox.isChecked()) 124 "PreferUnbundle", self.preferUnbundleCheckBox.isChecked()
123 self.__plugin.setPreferences( 125 )
124 "PreferUnbundle", self.preferUnbundleCheckBox.isChecked())
125 # cleanup 126 # cleanup
126 self.__plugin.setPreferences( 127 self.__plugin.setPreferences("CleanupPatterns", self.cleanupPatternEdit.text())
127 "CleanupPatterns", self.cleanupPatternEdit.text())
128 # revert 128 # revert
129 self.__plugin.setPreferences( 129 self.__plugin.setPreferences("CreateBackup", self.backupCheckBox.isChecked())
130 "CreateBackup", self.backupCheckBox.isChecked())
131 # merge 130 # merge
132 self.__plugin.setPreferences( 131 self.__plugin.setPreferences(
133 "InternalMerge", self.internalMergeCheckBox.isChecked()) 132 "InternalMerge", self.internalMergeCheckBox.isChecked()
134 133 )
134
135 @pyqtSlot() 135 @pyqtSlot()
136 def on_configButton_clicked(self): 136 def on_configButton_clicked(self):
137 """ 137 """
138 Private slot to edit the (per user) Mercurial configuration file. 138 Private slot to edit the (per user) Mercurial configuration file.
139 """ 139 """
140 from ..HgUserConfigDialog import HgUserConfigDialog 140 from ..HgUserConfigDialog import HgUserConfigDialog
141 from ..HgUtilities import hgVersion 141 from ..HgUtilities import hgVersion
142 142
143 dlg = HgUserConfigDialog(version=hgVersion(self.__plugin)[1]) 143 dlg = HgUserConfigDialog(version=hgVersion(self.__plugin)[1])
144 dlg.exec() 144 dlg.exec()
145 145
146 @pyqtSlot() 146 @pyqtSlot()
147 def on_installButton_clicked(self): 147 def on_installButton_clicked(self):
148 """ 148 """
149 Private slot to install Mercurial alongside eric7. 149 Private slot to install Mercurial alongside eric7.
150 """ 150 """
151 pip = ericApp().getObject("Pip") 151 pip = ericApp().getObject("Pip")
152 pip.installPackages(["mercurial"], 152 pip.installPackages(["mercurial"], interpreter=Globals.getPythonExecutable())
153 interpreter=Globals.getPythonExecutable())
154 self.installButton.setEnabled(not self.__mercurialInstalled()) 153 self.installButton.setEnabled(not self.__mercurialInstalled())
155 154
156 def __mercurialInstalled(self): 155 def __mercurialInstalled(self):
157 """ 156 """
158 Private method to check, if Mercurial is installed alongside eric7. 157 Private method to check, if Mercurial is installed alongside eric7.
159 158
160 @return flag indicating an installed Mercurial executable 159 @return flag indicating an installed Mercurial executable
161 @rtype bool 160 @rtype bool
162 """ 161 """
163 hg = HgUtilities.getHgExecutable() 162 hg = HgUtilities.getHgExecutable()
164 # assume local installation, if the path is absolute 163 # assume local installation, if the path is absolute

eric ide

mercurial