Fri, 21 Oct 2016 20:01:56 +0200
Continued refactoring the Mercurial user config management code.
--- a/Documentation/Source/eric6.Plugins.VcsPlugins.vcsMercurial.HgUserConfig.html Fri Oct 21 18:39:56 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -<!DOCTYPE html> -<html><head> -<title>eric6.Plugins.VcsPlugins.vcsMercurial.HgUserConfig</title> -<meta charset="UTF-8"> -<style> -body { - background: #EDECE6; - margin: 0em 1em 10em 1em; - color: black; -} - -h1 { color: white; background: #85774A; } -h2 { color: white; background: #85774A; } -h3 { color: white; background: #9D936E; } -h4 { color: white; background: #9D936E; } - -a { color: #BA6D36; } - -</style> -</head> -<body><a NAME="top" ID="top"></a> -<h1>eric6.Plugins.VcsPlugins.vcsMercurial.HgUserConfig</h1> -<p> -Module implementing the Mercurial version control plugin. -</p> -<h3>Global Attributes</h3> -<table> -<tr><td>_UserEditor</td></tr><tr><td>__all__</td></tr> -</table> -<h3>Classes</h3> -<table> -<tr><td>None</td></tr> -</table> -<h3>Functions</h3> -<table> -<tr> -<td><a href="#hgEditUserConfig">hgEditUserConfig</a></td> -<td>Module function used to edit the user configuration file.</td> -</tr> -</table> -<hr /><hr /> -<a NAME="hgEditUserConfig" ID="hgEditUserConfig"></a> -<h2>hgEditUserConfig</h2> -<b>hgEditUserConfig</b>(<i>version=(0, 0)</i>) -<p> - Module function used to edit the user configuration file. -</p><dl> -<dt><i>version</i></dt> -<dd> -Mercurial version info (tuple of two integers) -</dd> -</dl> -<div align="right"><a href="#top">Up</a></div> -<hr /> -</body></html> \ No newline at end of file
--- a/Documentation/Source/eric6.Plugins.VcsPlugins.vcsMercurial.HgUserConfigDataDialog.html Fri Oct 21 18:39:56 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,100 +0,0 @@ -<!DOCTYPE html> -<html><head> -<title>eric6.Plugins.VcsPlugins.vcsMercurial.HgUserConfigDataDialog</title> -<meta charset="UTF-8"> -<style> -body { - background: #EDECE6; - margin: 0em 1em 10em 1em; - color: black; -} - -h1 { color: white; background: #85774A; } -h2 { color: white; background: #85774A; } -h3 { color: white; background: #9D936E; } -h4 { color: white; background: #9D936E; } - -a { color: #BA6D36; } - -</style> -</head> -<body><a NAME="top" ID="top"></a> -<h1>eric6.Plugins.VcsPlugins.vcsMercurial.HgUserConfigDataDialog</h1> -<p> -Module implementing a dialog to enter some user data. -</p> -<h3>Global Attributes</h3> -<table> -<tr><td>None</td></tr> -</table> -<h3>Classes</h3> -<table> -<tr> -<td><a href="#HgUserConfigDataDialog">HgUserConfigDataDialog</a></td> -<td>Class implementing a dialog to enter some user data.</td> -</tr> -</table> -<h3>Functions</h3> -<table> -<tr><td>None</td></tr> -</table> -<hr /><hr /> -<a NAME="HgUserConfigDataDialog" ID="HgUserConfigDataDialog"></a> -<h2>HgUserConfigDataDialog</h2> -<p> - Class implementing a dialog to enter some user data. -</p> -<h3>Derived from</h3> -QDialog, Ui_HgUserConfigDataDialog -<h3>Class Attributes</h3> -<table> -<tr><td>None</td></tr> -</table> -<h3>Class Methods</h3> -<table> -<tr><td>None</td></tr> -</table> -<h3>Methods</h3> -<table> -<tr> -<td><a href="#HgUserConfigDataDialog.__init__">HgUserConfigDataDialog</a></td> -<td>Constructor</td> -</tr><tr> -<td><a href="#HgUserConfigDataDialog.getData">getData</a></td> -<td>Public method to retrieve the entered data.</td> -</tr> -</table> -<h3>Static Methods</h3> -<table> -<tr><td>None</td></tr> -</table> -<a NAME="HgUserConfigDataDialog.__init__" ID="HgUserConfigDataDialog.__init__"></a> -<h4>HgUserConfigDataDialog (Constructor)</h4> -<b>HgUserConfigDataDialog</b>(<i>version=(0, 0), parent=None</i>) -<p> - Constructor -</p><dl> -<dt><i>version</i></dt> -<dd> -Mercurial version info (tuple of two integers) -</dd><dt><i>parent</i></dt> -<dd> -reference to the parent widget (QWidget) -</dd> -</dl><a NAME="HgUserConfigDataDialog.getData" ID="HgUserConfigDataDialog.getData"></a> -<h4>HgUserConfigDataDialog.getData</h4> -<b>getData</b>(<i></i>) -<p> - Public method to retrieve the entered data. -</p><dl> -<dt>Returns:</dt> -<dd> -tuple with user's first name, last name, email address, - list of activated extensions and dictionary with extension data - (tuple of three strings, a list of strings and a dictionary with - extension name as key) -</dd> -</dl> -<div align="right"><a href="#top">Up</a></div> -<hr /> -</body></html> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Documentation/Source/eric6.Plugins.VcsPlugins.vcsMercurial.HgUserConfigDialog.html Fri Oct 21 20:01:56 2016 +0200 @@ -0,0 +1,100 @@ +<!DOCTYPE html> +<html><head> +<title>eric6.Plugins.VcsPlugins.vcsMercurial.HgUserConfigDataDialog</title> +<meta charset="UTF-8"> +<style> +body { + background: #EDECE6; + margin: 0em 1em 10em 1em; + color: black; +} + +h1 { color: white; background: #85774A; } +h2 { color: white; background: #85774A; } +h3 { color: white; background: #9D936E; } +h4 { color: white; background: #9D936E; } + +a { color: #BA6D36; } + +</style> +</head> +<body><a NAME="top" ID="top"></a> +<h1>eric6.Plugins.VcsPlugins.vcsMercurial.HgUserConfigDataDialog</h1> +<p> +Module implementing a dialog to enter some user data. +</p> +<h3>Global Attributes</h3> +<table> +<tr><td>None</td></tr> +</table> +<h3>Classes</h3> +<table> +<tr> +<td><a href="#HgUserConfigDataDialog">HgUserConfigDataDialog</a></td> +<td>Class implementing a dialog to enter some user data.</td> +</tr> +</table> +<h3>Functions</h3> +<table> +<tr><td>None</td></tr> +</table> +<hr /><hr /> +<a NAME="HgUserConfigDataDialog" ID="HgUserConfigDataDialog"></a> +<h2>HgUserConfigDataDialog</h2> +<p> + Class implementing a dialog to enter some user data. +</p> +<h3>Derived from</h3> +QDialog, Ui_HgUserConfigDataDialog +<h3>Class Attributes</h3> +<table> +<tr><td>None</td></tr> +</table> +<h3>Class Methods</h3> +<table> +<tr><td>None</td></tr> +</table> +<h3>Methods</h3> +<table> +<tr> +<td><a href="#HgUserConfigDataDialog.__init__">HgUserConfigDataDialog</a></td> +<td>Constructor</td> +</tr><tr> +<td><a href="#HgUserConfigDataDialog.getData">getData</a></td> +<td>Public method to retrieve the entered data.</td> +</tr> +</table> +<h3>Static Methods</h3> +<table> +<tr><td>None</td></tr> +</table> +<a NAME="HgUserConfigDataDialog.__init__" ID="HgUserConfigDataDialog.__init__"></a> +<h4>HgUserConfigDataDialog (Constructor)</h4> +<b>HgUserConfigDataDialog</b>(<i>version=(0, 0), parent=None</i>) +<p> + Constructor +</p><dl> +<dt><i>version</i></dt> +<dd> +Mercurial version info (tuple of two integers) +</dd><dt><i>parent</i></dt> +<dd> +reference to the parent widget (QWidget) +</dd> +</dl><a NAME="HgUserConfigDataDialog.getData" ID="HgUserConfigDataDialog.getData"></a> +<h4>HgUserConfigDataDialog.getData</h4> +<b>getData</b>(<i></i>) +<p> + Public method to retrieve the entered data. +</p><dl> +<dt>Returns:</dt> +<dd> +tuple with user's first name, last name, email address, + list of activated extensions and dictionary with extension data + (tuple of three strings, a list of strings and a dictionary with + extension name as key) +</dd> +</dl> +<div align="right"><a href="#top">Up</a></div> +<hr /> +</body></html> \ No newline at end of file
--- a/Plugins/VcsPlugins/vcsMercurial/ConfigurationPage/MercurialPage.py Fri Oct 21 18:39:56 2016 +0200 +++ b/Plugins/VcsPlugins/vcsMercurial/ConfigurationPage/MercurialPage.py Fri Oct 21 20:01:56 2016 +0200 @@ -111,5 +111,6 @@ """ Private slot to edit the (per user) Mercurial configuration file. """ - from ..HgUserConfig import hgEditUserConfig - hgEditUserConfig() + from ..HgUserConfigDialog import HgUserConfigDialog + dlg = HgUserConfigDialog() + dlg.exec_()
--- a/Plugins/VcsPlugins/vcsMercurial/HgUserConfig.py Fri Oct 21 18:39:56 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2010 - 2016 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing the Mercurial version control plugin. -""" - -from __future__ import unicode_literals - -import os - -from PyQt5.QtWidgets import QDialog - -from QScintilla.MiniEditor import MiniEditor - - -__all__ = ["hgEditUserConfig"] - -_UserEditor = None - - -def hgEditUserConfig(version=(0, 0)): - """ - Module function used to edit the user configuration file. - - @param version Mercurial version info (tuple of two integers) - """ - global _UserEditor - - from .HgUtilities import getConfigPath - cfgFile = getConfigPath() - if not os.path.exists(cfgFile): - # open dialog to enter the initial data - from .HgUserConfigDataDialog import HgUserConfigDataDialog - dlg = HgUserConfigDataDialog(version=version) - if dlg.exec_() == QDialog.Accepted: - firstName, lastName, email, extensions, extensionsData = \ - dlg.getData() - else: - firstName, lastName, email, extensions, extensionsData = ( - "Firstname", "Lastname", "email_address", [], {}) - try: - f = open(cfgFile, "w") - f.write("[ui]\n") - f.write("username = {0} {1} <{2}>\n".format( - firstName, lastName, email)) - if extensions: - f.write("\n[extensions]\n") - f.write(" =\n".join(extensions)) - f.write(" =\n") # complete the last line - if "largefiles" in extensionsData: - dataDict = extensionsData["largefiles"] - f.write("\n[largefiles]\n") - if "minsize" in dataDict: - f.write("minsize = {0}\n".format(dataDict["minsize"])) - if "patterns" in dataDict: - f.write("patterns =\n") - f.write(" {0}\n".format( - "\n ".join(dataDict["patterns"]))) - f.close() - except (IOError, OSError): - # ignore these - pass - _UserEditor = MiniEditor(cfgFile, "Properties") - _UserEditor.show()
--- a/Plugins/VcsPlugins/vcsMercurial/HgUserConfigDataDialog.py Fri Oct 21 18:39:56 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2014 - 2016 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing a dialog to enter some user data. -""" - -from __future__ import unicode_literals - -from PyQt5.QtWidgets import QDialog - -from .Ui_HgUserConfigDataDialog import Ui_HgUserConfigDataDialog - - -class HgUserConfigDataDialog(QDialog, Ui_HgUserConfigDataDialog): - """ - Class implementing a dialog to enter some user data. - """ - def __init__(self, version=(0, 0), parent=None): - """ - Constructor - - @param version Mercurial version info (tuple of two integers) - @param parent reference to the parent widget (QWidget) - """ - super(HgUserConfigDataDialog, self).__init__(parent) - self.setupUi(self) - - msh = self.minimumSizeHint() - self.resize(max(self.width(), msh.width()), msh.height()) - - def getData(self): - """ - Public method to retrieve the entered data. - - @return tuple with user's first name, last name, email address, - list of activated extensions and dictionary with extension data - (tuple of three strings, a list of strings and a dictionary with - extension name as key) - """ - extensions = [] - extensionsData = {} - - if self.fetchCheckBox.isChecked(): - extensions.append("fetch") - if self.gpgCheckBox.isChecked(): - extensions.append("gpg") - if self.purgeCheckBox.isChecked(): - extensions.append("purge") - if self.queuesCheckBox.isChecked(): - extensions.append("mq") - if self.rebaseCheckBox.isChecked(): - extensions.append("rebase") - if self.shelveCheckBox.isChecked(): - extensions.append("shelve") - if self.largefilesCheckBox.isChecked(): - extensions.append("largefiles") - largefilesDataDict = {} - lfFileSize = self.lfFileSizeSpinBox.value() - if lfFileSize != 10: # default value is 10 MB - largefilesDataDict["minsize"] = lfFileSize - lfFilePatterns = self.lfFilePatternsEdit.text() - if lfFilePatterns: - largefilesDataDict["patterns"] = lfFilePatterns.split() - if largefilesDataDict: - extensionsData["largefiles"] = largefilesDataDict - - return ( - self.firstNameEdit.text(), - self.lastNameEdit.text(), - self.emailEdit.text(), - extensions, - extensionsData, - )
--- a/Plugins/VcsPlugins/vcsMercurial/HgUserConfigDataDialog.ui Fri Oct 21 18:39:56 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,300 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>HgUserConfigDataDialog</class> - <widget class="QDialog" name="HgUserConfigDataDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>400</width> - <height>468</height> - </rect> - </property> - <property name="windowTitle"> - <string>Mercurial User Data</string> - </property> - <property name="sizeGripEnabled"> - <bool>true</bool> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QGroupBox" name="groupBox"> - <property name="title"> - <string>User Data</string> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>First Name:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="E5ClearableLineEdit" name="firstNameEdit"> - <property name="toolTip"> - <string>Enter the first name</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Last Name:</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="E5ClearableLineEdit" name="lastNameEdit"> - <property name="toolTip"> - <string>Enter the last name</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Email:</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="E5ClearableLineEdit" name="emailEdit"> - <property name="toolTip"> - <string>Enter the email address</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="groupBox_2"> - <property name="title"> - <string>Extensions</string> - </property> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="0" column="0"> - <widget class="QCheckBox" name="fetchCheckBox"> - <property name="toolTip"> - <string>Select to activate the fetch extension</string> - </property> - <property name="text"> - <string>Fetch</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QCheckBox" name="gpgCheckBox"> - <property name="toolTip"> - <string>Select to activate the GPG extension</string> - </property> - <property name="text"> - <string>GPG</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QCheckBox" name="largefilesCheckBox"> - <property name="toolTip"> - <string>Select to activate the largefiles extension</string> - </property> - <property name="text"> - <string>Large Files</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QCheckBox" name="purgeCheckBox"> - <property name="toolTip"> - <string>Select to activate the Purge extension</string> - </property> - <property name="text"> - <string>Purge</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QCheckBox" name="queuesCheckBox"> - <property name="toolTip"> - <string>Select to activate the queues extension</string> - </property> - <property name="text"> - <string>Queues</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QCheckBox" name="rebaseCheckBox"> - <property name="toolTip"> - <string>Select to activate the rebase extension</string> - </property> - <property name="text"> - <string>Rebase</string> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QCheckBox" name="shelveCheckBox"> - <property name="toolTip"> - <string>Select to activate the shelve extension</string> - </property> - <property name="text"> - <string>Shelve</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="largefilesGroup"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="title"> - <string>Large Files</string> - </property> - <layout class="QGridLayout" name="gridLayout_3"> - <item row="0" column="0"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>Minimum file size:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QSpinBox" name="lfFileSizeSpinBox"> - <property name="toolTip"> - <string>Enter the minimum file size in MB for files to be treated as Large Files</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - <property name="suffix"> - <string> MB</string> - </property> - <property name="minimum"> - <number>1</number> - </property> - <property name="value"> - <number>10</number> - </property> - </widget> - </item> - <item row="0" column="2"> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>215</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_5"> - <property name="text"> - <string>Patterns:</string> - </property> - </widget> - </item> - <item row="1" column="1" colspan="2"> - <widget class="QLineEdit" name="lfFilePatternsEdit"> - <property name="toolTip"> - <string>Enter file patterns (space separated) for files to be treated as Large Files</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <customwidgets> - <customwidget> - <class>E5ClearableLineEdit</class> - <extends>QLineEdit</extends> - <header>E5Gui/E5LineEdit.h</header> - </customwidget> - </customwidgets> - <tabstops> - <tabstop>firstNameEdit</tabstop> - <tabstop>lastNameEdit</tabstop> - <tabstop>emailEdit</tabstop> - <tabstop>fetchCheckBox</tabstop> - <tabstop>gpgCheckBox</tabstop> - <tabstop>largefilesCheckBox</tabstop> - <tabstop>purgeCheckBox</tabstop> - <tabstop>queuesCheckBox</tabstop> - <tabstop>rebaseCheckBox</tabstop> - <tabstop>shelveCheckBox</tabstop> - <tabstop>lfFileSizeSpinBox</tabstop> - <tabstop>lfFilePatternsEdit</tabstop> - <tabstop>buttonBox</tabstop> - </tabstops> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>HgUserConfigDataDialog</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>257</x> - <y>378</y> - </hint> - <hint type="destinationlabel"> - <x>157</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>HgUserConfigDataDialog</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>325</x> - <y>378</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>largefilesCheckBox</sender> - <signal>toggled(bool)</signal> - <receiver>largefilesGroup</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>225</x> - <y>173</y> - </hint> - <hint type="destinationlabel"> - <x>55</x> - <y>276</y> - </hint> - </hints> - </connection> - </connections> -</ui>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Plugins/VcsPlugins/vcsMercurial/HgUserConfigDialog.py Fri Oct 21 20:01:56 2016 +0200 @@ -0,0 +1,135 @@ +# -*- coding: utf-8 -*- + +# Copyright (c) 2014 - 2016 Detlev Offenbach <detlev@die-offenbachs.de> +# + +""" +Module implementing a dialog to enter some user data. +""" + +from __future__ import unicode_literals + +from PyQt5.QtCore import pyqtSlot +from PyQt5.QtWidgets import QDialog + +from Globals.E5ConfigParser import E5ConfigParser + +from .HgUtilities import getConfigPath + +from .Ui_HgUserConfigDialog import Ui_HgUserConfigDialog + + +class HgUserConfigDialog(QDialog, Ui_HgUserConfigDialog): + """ + Class implementing a dialog to enter some user data. + """ + def __init__(self, version=(0, 0), parent=None): + """ + Constructor + + @param version Mercurial version info (tuple of two integers) + @param parent reference to the parent widget (QWidget) + """ + super(HgUserConfigDialog, self).__init__(parent) + self.setupUi(self) + + msh = self.minimumSizeHint() + self.resize(max(self.width(), msh.width()), msh.height()) + + self.__config = None + self.readUserConfig() + + def writeUserConfig(self): + """ + Public method to write the user configuration file. + """ + if self.__config is None: + self.__config = E5ConfigParser() + + self.__config["ui"] = { + "username": "{0} <{1}>".format( + self.userNameEdit.text(), + self.emailEdit.text(), + ) + } + self.__config["extensions"] = {} + if self.fetchCheckBox.isChecked(): + self.__config["extensions"]["fetch"] = "" + if self.gpgCheckBox.isChecked(): + self.__config["extensions"]["gpg"] = "" + if self.purgeCheckBox.isChecked(): + self.__config["extensions"]["purge"] = "" + if self.queuesCheckBox.isChecked(): + self.__config["extensions"]["mq"] = "" + if self.rebaseCheckBox.isChecked(): + self.__config["extensions"]["rebase"] = "" + if self.shelveCheckBox.isChecked(): + self.__config["extensions"]["shelve"] = "" + if self.largefilesCheckBox.isChecked(): + self.__config["extensions"]["largefiles"] = "" + self.__config["largefiles"] = { + "minsize": self.lfFileSizeSpinBox.value(), + } + lfFilePatterns = self.lfFilePatternsEdit.text() + if lfFilePatterns: + self.__config["largefiles"]["patterns"] = lfFilePatterns + + cfgFile = getConfigPath() + with open(cfgFile, "w") as configFile: + self.__config.write(configFile) + + def readUserConfig(self): + """ + Public method to read the user configuration file. + """ + cfgFile = getConfigPath() + + self.__config = E5ConfigParser() + if self.__config.read(cfgFile): + # step 1: extract user name and email + try: + username = self.__config["ui"]["username"].strip() + if "<" in username and username.endswith(">"): + name, email = username[:-1].rsplit("<", 1) + else: + name = username + email = "" + self.userNameEdit.setText(name.strip()), + self.emailEdit.setText(email.strip()), + except KeyError: + pass + + # step 2: extract extensions information + if "extensions" in self.__config: + self.fetchCheckBox.setChecked( + "fetch" in self.__config["extensions"]) + self.gpgCheckBox.setChecked( + "gpg" in self.__config["extensions"]) + self.purgeCheckBox.setChecked( + "purge" in self.__config["extensions"]) + self.queuesCheckBox.setChecked( + "mq" in self.__config["extensions"]) + self.rebaseCheckBox.setChecked( + "rebase" in self.__config["extensions"]) + self.shelveCheckBox.setChecked( + "shelve" in self.__config["extensions"]) + self.largefilesCheckBox.setChecked( + "largefiles" in self.__config["extensions"]) + + # step 3: extract large files information + if "largefiles" in self.__config: + if "minsize" in self.__config["largefiles"]: + self.lfFileSizeSpinBox.setValue( + self.__config.getint("largefiles", "minsize")) + if "patterns" in self.__config["largefiles"]: + self.lfFilePatternsEdit.setText( + self.__config["largefiles"]["patterns"]) + + @pyqtSlot() + def accept(self): + """ + Public slot to accept the dialog. + """ + self.writeUserConfig() + + super(HgUserConfigDialog, self).accept()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Plugins/VcsPlugins/vcsMercurial/HgUserConfigDialog.ui Fri Oct 21 20:01:56 2016 +0200 @@ -0,0 +1,285 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>HgUserConfigDialog</class> + <widget class="QDialog" name="HgUserConfigDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>436</height> + </rect> + </property> + <property name="windowTitle"> + <string>Mercurial User Data</string> + </property> + <property name="sizeGripEnabled"> + <bool>true</bool> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string>User Data</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Name:</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="E5ClearableLineEdit" name="userNameEdit"> + <property name="toolTip"> + <string>Enter the user name</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Email:</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="E5ClearableLineEdit" name="emailEdit"> + <property name="toolTip"> + <string>Enter the email address</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox_2"> + <property name="title"> + <string>Extensions</string> + </property> + <layout class="QGridLayout" name="gridLayout_2"> + <item row="0" column="0"> + <widget class="QCheckBox" name="fetchCheckBox"> + <property name="toolTip"> + <string>Select to activate the fetch extension</string> + </property> + <property name="text"> + <string>Fetch</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QCheckBox" name="gpgCheckBox"> + <property name="toolTip"> + <string>Select to activate the GPG extension</string> + </property> + <property name="text"> + <string>GPG</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QCheckBox" name="largefilesCheckBox"> + <property name="toolTip"> + <string>Select to activate the largefiles extension</string> + </property> + <property name="text"> + <string>Large Files</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QCheckBox" name="purgeCheckBox"> + <property name="toolTip"> + <string>Select to activate the Purge extension</string> + </property> + <property name="text"> + <string>Purge</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QCheckBox" name="queuesCheckBox"> + <property name="toolTip"> + <string>Select to activate the queues extension</string> + </property> + <property name="text"> + <string>Queues</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QCheckBox" name="rebaseCheckBox"> + <property name="toolTip"> + <string>Select to activate the rebase extension</string> + </property> + <property name="text"> + <string>Rebase</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QCheckBox" name="shelveCheckBox"> + <property name="toolTip"> + <string>Select to activate the shelve extension</string> + </property> + <property name="text"> + <string>Shelve</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="largefilesGroup"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="title"> + <string>Large Files</string> + </property> + <layout class="QGridLayout" name="gridLayout_3"> + <item row="0" column="0"> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>Minimum file size:</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QSpinBox" name="lfFileSizeSpinBox"> + <property name="toolTip"> + <string>Enter the minimum file size in MB for files to be treated as Large Files</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + <property name="suffix"> + <string> MB</string> + </property> + <property name="minimum"> + <number>1</number> + </property> + <property name="value"> + <number>10</number> + </property> + </widget> + </item> + <item row="0" column="2"> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>215</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_5"> + <property name="text"> + <string>Patterns:</string> + </property> + </widget> + </item> + <item row="1" column="1" colspan="2"> + <widget class="QLineEdit" name="lfFilePatternsEdit"> + <property name="toolTip"> + <string>Enter file patterns (space separated) for files to be treated as Large Files</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <customwidgets> + <customwidget> + <class>E5ClearableLineEdit</class> + <extends>QLineEdit</extends> + <header>E5Gui/E5LineEdit.h</header> + </customwidget> + </customwidgets> + <tabstops> + <tabstop>userNameEdit</tabstop> + <tabstop>emailEdit</tabstop> + <tabstop>fetchCheckBox</tabstop> + <tabstop>gpgCheckBox</tabstop> + <tabstop>largefilesCheckBox</tabstop> + <tabstop>purgeCheckBox</tabstop> + <tabstop>queuesCheckBox</tabstop> + <tabstop>rebaseCheckBox</tabstop> + <tabstop>shelveCheckBox</tabstop> + <tabstop>lfFileSizeSpinBox</tabstop> + <tabstop>lfFilePatternsEdit</tabstop> + <tabstop>buttonBox</tabstop> + </tabstops> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>HgUserConfigDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>257</x> + <y>378</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>HgUserConfigDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>325</x> + <y>378</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>largefilesCheckBox</sender> + <signal>toggled(bool)</signal> + <receiver>largefilesGroup</receiver> + <slot>setEnabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>225</x> + <y>173</y> + </hint> + <hint type="destinationlabel"> + <x>55</x> + <y>276</y> + </hint> + </hints> + </connection> + </connections> +</ui>
--- a/Plugins/VcsPlugins/vcsMercurial/hg.py Fri Oct 21 18:39:56 2016 +0200 +++ b/Plugins/VcsPlugins/vcsMercurial/hg.py Fri Oct 21 20:01:56 2016 +0200 @@ -2305,8 +2305,9 @@ """ Public method used to edit the user configuration file. """ - from .HgUserConfig import hgEditUserConfig - hgEditUserConfig(version=self.version) + from .HgUserConfigDialog import HgUserConfigDialog + dlg = HgUserConfigDialog(version=self.version) + dlg.exec_() def hgEditConfig(self, name, withLargefiles=True, largefilesData=None): """
--- a/eric6.e4p Fri Oct 21 18:39:56 2016 +0200 +++ b/eric6.e4p Fri Oct 21 20:01:56 2016 +0200 @@ -573,8 +573,7 @@ <Source>Plugins/VcsPlugins/vcsMercurial/HgSummaryDialog.py</Source> <Source>Plugins/VcsPlugins/vcsMercurial/HgTagBranchListDialog.py</Source> <Source>Plugins/VcsPlugins/vcsMercurial/HgTagDialog.py</Source> - <Source>Plugins/VcsPlugins/vcsMercurial/HgUserConfig.py</Source> - <Source>Plugins/VcsPlugins/vcsMercurial/HgUserConfigDataDialog.py</Source> + <Source>Plugins/VcsPlugins/vcsMercurial/HgUserConfigDialog.py</Source> <Source>Plugins/VcsPlugins/vcsMercurial/HgUtilities.py</Source> <Source>Plugins/VcsPlugins/vcsMercurial/LargefilesExtension/LfConvertDataDialog.py</Source> <Source>Plugins/VcsPlugins/vcsMercurial/LargefilesExtension/LfRevisionsInputDialog.py</Source> @@ -1634,7 +1633,7 @@ <Form>Plugins/VcsPlugins/vcsMercurial/HgSummaryDialog.ui</Form> <Form>Plugins/VcsPlugins/vcsMercurial/HgTagBranchListDialog.ui</Form> <Form>Plugins/VcsPlugins/vcsMercurial/HgTagDialog.ui</Form> - <Form>Plugins/VcsPlugins/vcsMercurial/HgUserConfigDataDialog.ui</Form> + <Form>Plugins/VcsPlugins/vcsMercurial/HgUserConfigDialog.ui</Form> <Form>Plugins/VcsPlugins/vcsMercurial/LargefilesExtension/LfConvertDataDialog.ui</Form> <Form>Plugins/VcsPlugins/vcsMercurial/LargefilesExtension/LfRevisionsInputDialog.ui</Form> <Form>Plugins/VcsPlugins/vcsMercurial/PurgeExtension/HgPurgeListDialog.ui</Form> @@ -1950,6 +1949,7 @@ <Other>Dictionaries</Other> <Other>Documentation/Help</Other> <Other>Documentation/Source</Other> + <Other>Documentation/Source/eric6.Plugins.VcsPlugins.vcsMercurial.HgUserConfigDialog.html</Other> <Other>Documentation/eric6-plugin.odt</Other> <Other>Documentation/eric6-plugin.pdf</Other> <Other>Documentation/mod_python.odt</Other>