10 from __future__ import unicode_literals # __IGNORE_WARNING__ |
10 from __future__ import unicode_literals # __IGNORE_WARNING__ |
11 |
11 |
12 import os |
12 import os |
13 |
13 |
14 from PyQt4.QtCore import pyqtSlot |
14 from PyQt4.QtCore import pyqtSlot |
|
15 from PyQt4.QtGui import QDialog |
15 |
16 |
16 from Preferences.ConfigurationPages.ConfigurationPageBase import ConfigurationPageBase |
17 from Preferences.ConfigurationPages.ConfigurationPageBase import ConfigurationPageBase |
17 from .Ui_MercurialPage import Ui_MercurialPage |
18 from .Ui_MercurialPage import Ui_MercurialPage |
18 |
19 |
19 |
20 |
62 Private slot to edit the (per user) Mercurial configuration file. |
63 Private slot to edit the (per user) Mercurial configuration file. |
63 """ |
64 """ |
64 from QScintilla.MiniEditor import MiniEditor |
65 from QScintilla.MiniEditor import MiniEditor |
65 cfgFile = self.__plugin.getConfigPath() |
66 cfgFile = self.__plugin.getConfigPath() |
66 if not os.path.exists(cfgFile): |
67 if not os.path.exists(cfgFile): |
|
68 username = "" |
|
69 from .MercurialUserDataDialog import MercurialUserDataDialog |
|
70 dlg = MercurialUserDataDialog() |
|
71 if dlg.exec_() == QDialog.Accepted: |
|
72 name, email = dlg.getData() |
|
73 if name and email: |
|
74 username = "{0} <{1}>".format(name, email) |
|
75 elif name: |
|
76 username = name |
|
77 elif email: |
|
78 username = email |
67 try: |
79 try: |
68 f = open(cfgFile, "w") |
80 f = open(cfgFile, "w") |
|
81 f.write(os.linesep.join(["[ui]", "username = {0}".format(username), ""])) |
69 f.close() |
82 f.close() |
70 except (IOError, OSError): |
83 except (IOError, OSError): |
71 # ignore these |
84 # ignore these |
72 pass |
85 pass |
73 editor = MiniEditor(cfgFile, "Properties", self) |
86 editor = MiniEditor(cfgFile, "Properties", self) |