Started to refactor the Mercurial user config management code.

Thu, 20 Oct 2016 19:33:19 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 20 Oct 2016 19:33:19 +0200
changeset 5256
4720cbf7ab52
parent 5255
5fc76ccd369e
child 5257
005c59af7989
child 5258
cfca063afa07

Started to refactor the Mercurial user config management code.

Plugins/VcsPlugins/vcsMercurial/ConfigurationPage/MercurialPage.py file | annotate | diff | comparison | revisions
Plugins/VcsPlugins/vcsMercurial/hg.py file | annotate | diff | comparison | revisions
eric6.e4p file | annotate | diff | comparison | revisions
--- a/Plugins/VcsPlugins/vcsMercurial/ConfigurationPage/MercurialPage.py	Thu Oct 20 18:55:14 2016 +0200
+++ b/Plugins/VcsPlugins/vcsMercurial/ConfigurationPage/MercurialPage.py	Thu Oct 20 19:33:19 2016 +0200
@@ -9,10 +9,7 @@
 
 from __future__ import unicode_literals
 
-import os
-
 from PyQt5.QtCore import pyqtSlot
-from PyQt5.QtWidgets import QDialog
 
 from Preferences.ConfigurationPages.ConfigurationPageBase import \
     ConfigurationPageBase
@@ -114,38 +111,5 @@
         """
         Private slot to edit the (per user) Mercurial configuration file.
         """
-        from QScintilla.MiniEditor import MiniEditor
-        cfgFile = self.__plugin.getConfigPath()
-        if not os.path.exists(cfgFile):
-            from ..HgUserConfigDataDialog import HgUserConfigDataDialog
-            dlg = HgUserConfigDataDialog()
-            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
-        editor = MiniEditor(cfgFile, "Properties", self)
-        editor.show()
+        from ..HgUserConfig import hgEditUserConfig
+        hgEditUserConfig()
--- a/Plugins/VcsPlugins/vcsMercurial/hg.py	Thu Oct 20 18:55:14 2016 +0200
+++ b/Plugins/VcsPlugins/vcsMercurial/hg.py	Thu Oct 20 19:33:19 2016 +0200
@@ -108,7 +108,6 @@
         self.tagbranchList = None
         self.annotate = None
         self.repoEditor = None
-        self.userEditor = None
         self.serveDlg = None
         self.bookmarksListDlg = None
         self.bookmarksInOutDlg = None
@@ -2306,42 +2305,8 @@
         """
         Public method used to edit the user configuration file.
         """
-        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=self.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
-        self.userEditor = MiniEditor(cfgFile, "Properties")
-        self.userEditor.show()
+        from .HgUserConfig import hgEditUserConfig
+        hgEditUserConfig(version=self.version)
     
     def hgEditConfig(self, name, withLargefiles=True, largefilesData=None):
         """
--- a/eric6.e4p	Thu Oct 20 18:55:14 2016 +0200
+++ b/eric6.e4p	Thu Oct 20 19:33:19 2016 +0200
@@ -573,6 +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/HgUtilities.py</Source>
     <Source>Plugins/VcsPlugins/vcsMercurial/LargefilesExtension/LfConvertDataDialog.py</Source>
@@ -1928,14 +1929,14 @@
   <Interfaces/>
   <Others>
     <Other>.hgignore</Other>
+    <Other>APIs/Python/zope-2.10.7.api</Other>
+    <Other>APIs/Python/zope-2.11.2.api</Other>
+    <Other>APIs/Python/zope-3.3.1.api</Other>
     <Other>APIs/Python3/PyQt4.bas</Other>
     <Other>APIs/Python3/PyQt5.bas</Other>
     <Other>APIs/Python3/QScintilla2.bas</Other>
     <Other>APIs/Python3/eric6.api</Other>
     <Other>APIs/Python3/eric6.bas</Other>
-    <Other>APIs/Python/zope-2.10.7.api</Other>
-    <Other>APIs/Python/zope-2.11.2.api</Other>
-    <Other>APIs/Python/zope-3.3.1.api</Other>
     <Other>APIs/QSS/qss.api</Other>
     <Other>APIs/Ruby/Ruby-1.8.7.api</Other>
     <Other>APIs/Ruby/Ruby-1.8.7.bas</Other>

eric ide

mercurial