Fri, 24 Feb 2017 18:58:27 +0100
Added a repository URL history to the Mercurial plug-in and new project options dialog.
--- a/Plugins/PluginVcsMercurial.py Fri Feb 24 18:51:36 2017 +0100 +++ b/Plugins/PluginVcsMercurial.py Fri Feb 24 18:58:27 2017 +0100 @@ -143,12 +143,49 @@ if not e5App().getObject("PluginManager").isPluginLoaded( "PluginVcsMercurial"): Preferences.Prefs.settings.remove("Mercurial") + + +def clearPrivateData(): + """ + Module function to clear the private data of the plug-in. + """ + for key in ["RepositoryUrlHistory"]: + VcsMercurialPlugin.setPreferences(key, []) class VcsMercurialPlugin(QObject): """ Class implementing the Mercurial version control plugin. """ + MercurialDefaults = { + "StopLogOnCopy": True, # used in log browser + "LogLimit": 20, + "CommitMessages": 20, + "Commits": [], + "CommitAuthorsLimit": 20, + "CommitAuthors": [], + "PullUpdate": False, + "PreferUnbundle": False, + "ServerPort": 8000, + "ServerStyle": "", + "CleanupPatterns": "*.orig *.rej *~", + "CreateBackup": False, + "InternalMerge": False, + "Encoding": "utf-8", + "EncodingMode": "strict", + "ConsiderHidden": False, + "LogMessageColumnWidth": 30, + "LogBrowserGeometry": QByteArray(), + "LogBrowserSplitterStates": [QByteArray(), QByteArray(), + QByteArray()], + # mainSplitter, detailsSplitter, diffSplitter + "StatusDialogGeometry": QByteArray(), + "StatusDialogSplitterState": QByteArray(), + "MqStatusDialogGeometry": QByteArray(), + "MqStatusDialogSplitterState": QByteArray(), + "RepositoryUrlHistory": [], + } + def __init__(self, ui): """ Constructor @@ -158,34 +195,6 @@ super(VcsMercurialPlugin, self).__init__(ui) self.__ui = ui - self.__mercurialDefaults = { - "StopLogOnCopy": True, # used in log browser - "LogLimit": 20, - "CommitMessages": 20, - "Commits": [], - "CommitAuthorsLimit": 20, - "CommitAuthors": [], - "PullUpdate": False, - "PreferUnbundle": False, - "ServerPort": 8000, - "ServerStyle": "", - "CleanupPatterns": "*.orig *.rej *~", - "CreateBackup": False, - "InternalMerge": False, - "Encoding": "utf-8", - "EncodingMode": "strict", - "ConsiderHidden": False, - "LogMessageColumnWidth": 30, - "LogBrowserGeometry": QByteArray(), - "LogBrowserSplitterStates": [QByteArray(), QByteArray(), - QByteArray()], - # mainSplitter, detailsSplitter, diffSplitter - "StatusDialogGeometry": QByteArray(), - "StatusDialogSplitterState": QByteArray(), - "MqStatusDialogGeometry": QByteArray(), - "MqStatusDialogSplitterState": QByteArray(), - } - from VcsPlugins.vcsMercurial.ProjectHelper import HgProjectHelper self.__projectHelperObject = HgProjectHelper(None, None) try: @@ -248,7 +257,8 @@ tb.setVisible(True) tb.setEnabled(True) - def getPreferences(self, key): + @classmethod + def getPreferences(cls, key): """ Public method to retrieve the various settings. @@ -258,14 +268,14 @@ if key in ["StopLogOnCopy", "PullUpdate", "PreferUnbundle", "CreateBackup", "InternalMerge", "ConsiderHidden"]: return Preferences.toBool(Preferences.Prefs.settings.value( - "Mercurial/" + key, self.__mercurialDefaults[key])) + "Mercurial/" + key, cls.MercurialDefaults[key])) elif key in ["LogLimit", "CommitMessages", "CommitAuthorsLimit", "ServerPort", "LogMessageColumnWidth"]: return int(Preferences.Prefs.settings.value( - "Mercurial/" + key, self.__mercurialDefaults[key])) - elif key in ["Commits", "CommitAuthors"]: + "Mercurial/" + key, cls.MercurialDefaults[key])) + elif key in ["Commits", "CommitAuthors", "RepositoryUrlHistory"]: return Preferences.toList(Preferences.Prefs.settings.value( - "Mercurial/" + key)) + "Mercurial/" + key, cls.MercurialDefaults[key])) elif key in ["LogBrowserGeometry", "StatusDialogGeometry", "StatusDialogSplitterState", "MqStatusDialogGeometry", "MqStatusDialogSplitterState"]: @@ -274,19 +284,20 @@ if v is not None: return v else: - return self.__mercurialDefaults[key] + return cls.MercurialDefaults[key] elif key in ["LogBrowserSplitterStates"]: # list of QByteArray values states = Preferences.Prefs.settings.value("Mercurial/" + key) if states is not None: return states else: - return self.__mercurialDefaults[key] + return cls.MercurialDefaults[key] else: return Preferences.Prefs.settings.value( - "Mercurial/" + key, self.__mercurialDefaults[key]) + "Mercurial/" + key, cls.MercurialDefaults[key]) - def setPreferences(self, key, value): + @classmethod + def setPreferences(cls, key, value): """ Public method to store the various settings. @@ -303,11 +314,11 @@ """ args = [] if self.getPreferences("Encoding") != \ - self.__mercurialDefaults["Encoding"]: + self.MercurialDefaults["Encoding"]: args.append("--encoding") args.append(self.getPreferences("Encoding")) if self.getPreferences("EncodingMode") != \ - self.__mercurialDefaults["EncodingMode"]: + self.MercurialDefaults["EncodingMode"]: args.append("--encodingmode") args.append(self.getPreferences("EncodingMode")) if self.getPreferences("ConsiderHidden"):
--- a/Plugins/VcsPlugins/vcsMercurial/HgNewProjectOptionsDialog.py Fri Feb 24 18:51:36 2017 +0100 +++ b/Plugins/VcsPlugins/vcsMercurial/HgNewProjectOptionsDialog.py Fri Feb 24 18:58:27 2017 +0100 @@ -11,7 +11,7 @@ from __future__ import unicode_literals from PyQt5.QtCore import pyqtSlot, QUrl -from PyQt5.QtWidgets import QDialog, QDialogButtonBox +from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QComboBox from E5Gui.E5PathPicker import E5PathPickerModes @@ -20,6 +20,7 @@ import Utilities import Preferences +import UI.PixmapCache class HgNewProjectOptionsDialog(QDialog, Ui_HgNewProjectOptionsDialog): @@ -38,7 +39,19 @@ self.setupUi(self) self.vcsProjectDirPicker.setMode(E5PathPickerModes.DirectoryMode) + + self.__vcs = vcs + + vcsUrlHistory = self.__vcs.getPlugin().getPreferences( + "RepositoryUrlHistory") self.vcsUrlPicker.setMode(E5PathPickerModes.DirectoryMode) + self.vcsUrlPicker.setInsertPolicy(QComboBox.InsertAtTop) + self.vcsUrlPicker.setSizeAdjustPolicy( + QComboBox.AdjustToMinimumContentsLength) + self.vcsUrlPicker.setPathsList(vcsUrlHistory) + self.vcsUrlClearHistoryButton.setIcon( + UI.PixmapCache.getIcon("editDelete.png")) + self.vcsUrlPicker.setText("") ipath = Preferences.getMultiProject("Workspace") or \ Utilities.getHomeDir() @@ -48,8 +61,10 @@ ] self.vcsProjectDirPicker.setText(self.__initPaths[0]) - self.lfNoteLabel.setVisible(vcs.isExtensionActive("largefiles")) - self.largeCheckBox.setVisible(vcs.isExtensionActive("largefiles")) + self.lfNoteLabel.setVisible( + self.__vcs.isExtensionActive("largefiles")) + self.largeCheckBox.setVisible( + self.__vcs.isExtensionActive("largefiles")) self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) @@ -81,13 +96,27 @@ self.vcsUrlPicker.setPickerEnabled(url.scheme() == "file" or len(txt) == 0) + @pyqtSlot() + def on_vcsUrlClearHistoryButton_clicked(self): + """ + Private slot to clear the history of entered repository URLs. + """ + currentVcsUrl = self.vcsUrlPicker.text() + self.vcsUrlPicker.clear() + self.vcsUrlPicker.setText(currentVcsUrl) + + self.__saveHistory() + def getData(self): """ - Public slot to retrieve the data entered into the dialog. + Public slot to retrieve the data entered into the dialog and to + save the history of entered repository URLs. @return a tuple of a string (project directory) and a dictionary containing the data entered. """ + self.__saveHistory() + url = QUrl.fromUserInput(self.vcsUrlPicker.text().replace("\\", "/")) vcsdatadict = { "url": url.toString(QUrl.None_), @@ -95,3 +124,20 @@ "largefiles": self.largeCheckBox.isChecked(), } return (self.vcsProjectDirPicker.text(), vcsdatadict) + + def __saveHistory(self): + """ + Private method to save the repository URL history. + """ + url = self.vcsUrlPicker.text() + vcsUrlHistory = self.vcsUrlPicker.getPathItems() + if url not in vcsUrlHistory: + vcsUrlHistory.insert(0, url) + + # max. list sizes is hard coded to 20 entries + newVcsUrlHistory = [url for url in vcsUrlHistory if url] + if len(newVcsUrlHistory) > 20: + newVcsUrlHistory = newVcsUrlHistory[:20] + + self.__vcs.getPlugin().setPreferences( + "RepositoryUrlHistory", newVcsUrlHistory)
--- a/Plugins/VcsPlugins/vcsMercurial/HgNewProjectOptionsDialog.ui Fri Feb 24 18:51:36 2017 +0100 +++ b/Plugins/VcsPlugins/vcsMercurial/HgNewProjectOptionsDialog.ui Fri Feb 24 18:58:27 2017 +0100 @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>562</width> - <height>147</height> + <height>156</height> </rect> </property> <property name="windowTitle"> @@ -22,8 +22,18 @@ <bool>true</bool> </property> <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="TextLabel2"> + <property name="text"> + <string>&URL:</string> + </property> + <property name="buddy"> + <cstring>vcsUrlPicker</cstring> + </property> + </widget> + </item> <item row="0" column="1"> - <widget class="E5PathPicker" name="vcsUrlPicker" native="true"> + <widget class="E5ComboPathPicker" name="vcsUrlPicker" native="true"> <property name="sizePolicy"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <horstretch>0</horstretch> @@ -38,7 +48,44 @@ </property> </widget> </item> - <item row="2" column="1"> + <item row="0" column="2"> + <widget class="QToolButton" name="vcsUrlClearHistoryButton"> + <property name="toolTip"> + <string>Press to clear the history of entered repository URLs</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="vcsRevisionLabel"> + <property name="text"> + <string>&Revision:</string> + </property> + <property name="buddy"> + <cstring>vcsRevisionEdit</cstring> + </property> + </widget> + </item> + <item row="1" column="1" colspan="2"> + <widget class="QLineEdit" name="vcsRevisionEdit"> + <property name="toolTip"> + <string>Enter the revision the new project should be generated from</string> + </property> + <property name="whatsThis"> + <string/> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="TextLabel4"> + <property name="text"> + <string>Project &Directory:</string> + </property> + <property name="buddy"> + <cstring>vcsProjectDirPicker</cstring> + </property> + </widget> + </item> + <item row="2" column="1" colspan="2"> <widget class="E5PathPicker" name="vcsProjectDirPicker" native="true"> <property name="sizePolicy"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> @@ -59,54 +106,14 @@ </property> </widget> </item> - <item row="0" column="0"> - <widget class="QLabel" name="TextLabel2"> - <property name="text"> - <string>&URL:</string> - </property> - <property name="buddy"> - <cstring>vcsUrlPicker</cstring> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="vcsRevisionLabel"> - <property name="text"> - <string>&Revision:</string> - </property> - <property name="buddy"> - <cstring>vcsRevisionEdit</cstring> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="vcsRevisionEdit"> - <property name="toolTip"> - <string>Enter the revision the new project should be generated from</string> - </property> - <property name="whatsThis"> - <string/> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="TextLabel4"> - <property name="text"> - <string>Project &Directory:</string> - </property> - <property name="buddy"> - <cstring>vcsProjectDirPicker</cstring> - </property> - </widget> - </item> - <item row="3" column="0" colspan="2"> + <item row="3" column="0" colspan="3"> <widget class="QCheckBox" name="largeCheckBox"> <property name="text"> <string>Download all versions of all large files</string> </property> </widget> </item> - <item row="4" column="0" colspan="2"> + <item row="4" column="0" colspan="3"> <widget class="QLabel" name="lfNoteLabel"> <property name="text"> <string><b>Note:</b> This option increases the download time and volume.</string> @@ -116,7 +123,7 @@ </property> </widget> </item> - <item row="5" column="0" colspan="2"> + <item row="5" column="0" colspan="3"> <widget class="QDialogButtonBox" name="buttonBox"> <property name="orientation"> <enum>Qt::Horizontal</enum> @@ -136,9 +143,16 @@ <header>E5Gui/E5PathPicker.h</header> <container>1</container> </customwidget> + <customwidget> + <class>E5ComboPathPicker</class> + <extends>QWidget</extends> + <header>E5Gui/E5PathPicker.h</header> + <container>1</container> + </customwidget> </customwidgets> <tabstops> <tabstop>vcsUrlPicker</tabstop> + <tabstop>vcsUrlClearHistoryButton</tabstop> <tabstop>vcsRevisionEdit</tabstop> <tabstop>vcsProjectDirPicker</tabstop> <tabstop>largeCheckBox</tabstop>