Plugins/VcsPlugins/vcsMercurial/ConfigurationPage/MercurialPage.py

changeset 3231
a7c9914d1c41
parent 3160
209a07d7e401
child 3256
1a43351889d5
equal deleted inserted replaced
3230:2beb981f3b6d 3231:a7c9914d1c41
74 Private slot to edit the (per user) Mercurial configuration file. 74 Private slot to edit the (per user) Mercurial configuration file.
75 """ 75 """
76 from QScintilla.MiniEditor import MiniEditor 76 from QScintilla.MiniEditor import MiniEditor
77 cfgFile = self.__plugin.getConfigPath() 77 cfgFile = self.__plugin.getConfigPath()
78 if not os.path.exists(cfgFile): 78 if not os.path.exists(cfgFile):
79 username = "" 79 from ..HgUserConfigDataDialog import HgUserConfigDataDialog
80 from .MercurialUserDataDialog import MercurialUserDataDialog 80 dlg = HgUserConfigDataDialog()
81 dlg = MercurialUserDataDialog()
82 if dlg.exec_() == QDialog.Accepted: 81 if dlg.exec_() == QDialog.Accepted:
83 name, email = dlg.getData() 82 firstName, lastName, email, extensions = dlg.getData()
84 if name and email: 83 else:
85 username = "{0} <{1}>".format(name, email) 84 firstName, lastName, email, extensions = (
86 elif name: 85 "Firstname", "Lastname", "email_address", [])
87 username = name
88 elif email:
89 username = email
90 try: 86 try:
91 f = open(cfgFile, "w") 87 f = open(cfgFile, "w")
92 f.write(os.linesep.join(["[ui]", 88 f.write("[ui]\n")
93 "username = {0}".format(username), ""])) 89 f.write("username = {0} {1} <{2}>\n".format(
90 firstName, lastName, email))
91 if extensions:
92 f.write("\n[extensions]\n")
93 f.write(" =\n".join(extensions))
94 f.write(" =\n") # complete the last line
94 f.close() 95 f.close()
95 except (IOError, OSError): 96 except (IOError, OSError):
96 # ignore these 97 # ignore these
97 pass 98 pass
98 editor = MiniEditor(cfgFile, "Properties", self) 99 editor = MiniEditor(cfgFile, "Properties", self)

eric ide

mercurial