Plugins/VcsPlugins/vcsMercurial/ConfigurationPage/MercurialPage.py

changeset 2810
fe551b27f62e
parent 2405
d4b5f3bd4720
child 2847
1843ef6e2656
child 3008
7848489bcb92
equal deleted inserted replaced
2808:ea2b71538de1 2810:fe551b27f62e
8 """ 8 """
9 9
10 import os 10 import os
11 11
12 from PyQt4.QtCore import pyqtSlot 12 from PyQt4.QtCore import pyqtSlot
13 from PyQt4.QtGui import QDialog
13 14
14 from Preferences.ConfigurationPages.ConfigurationPageBase import ConfigurationPageBase 15 from Preferences.ConfigurationPages.ConfigurationPageBase import ConfigurationPageBase
15 from .Ui_MercurialPage import Ui_MercurialPage 16 from .Ui_MercurialPage import Ui_MercurialPage
16 17
17 18
60 Private slot to edit the (per user) Mercurial configuration file. 61 Private slot to edit the (per user) Mercurial configuration file.
61 """ 62 """
62 from QScintilla.MiniEditor import MiniEditor 63 from QScintilla.MiniEditor import MiniEditor
63 cfgFile = self.__plugin.getConfigPath() 64 cfgFile = self.__plugin.getConfigPath()
64 if not os.path.exists(cfgFile): 65 if not os.path.exists(cfgFile):
66 username = ""
67 from .MercurialUserDataDialog import MercurialUserDataDialog
68 dlg = MercurialUserDataDialog()
69 if dlg.exec_() == QDialog.Accepted:
70 name, email = dlg.getData()
71 if name and email:
72 username = "{0} <{1}>".format(name, email)
73 elif name:
74 username = name
75 elif email:
76 username = email
65 try: 77 try:
66 f = open(cfgFile, "w") 78 f = open(cfgFile, "w")
79 f.write(os.linesep.join(["[ui]", "username = {0}".format(username), ""]))
67 f.close() 80 f.close()
68 except (IOError, OSError): 81 except (IOError, OSError):
69 # ignore these 82 # ignore these
70 pass 83 pass
71 editor = MiniEditor(cfgFile, "Properties", self) 84 editor = MiniEditor(cfgFile, "Properties", self)

eric ide

mercurial