Plugins/VcsPlugins/vcsMercurial/hg.py

changeset 3231
a7c9914d1c41
parent 3227
520d79af33af
child 3242
a7e006073658
diff -r 2beb981f3b6d -r a7c9914d1c41 Plugins/VcsPlugins/vcsMercurial/hg.py
--- a/Plugins/VcsPlugins/vcsMercurial/hg.py	Sat Jan 25 18:10:09 2014 +0100
+++ b/Plugins/VcsPlugins/vcsMercurial/hg.py	Sun Jan 26 15:49:14 2014 +0100
@@ -2170,11 +2170,23 @@
         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 = dlg.getData()
+            else:
+                firstName, lastName, email, extensions = (
+                    "Firstname", "Lastname", "email_address", [])
             try:
-                # TODO: open a dialog to ask for the basic data
                 f = open(cfgFile, "w")
-                f.write("[ui]\nusername = Firstname Lastname"
-                        " <email_address>\n")
+                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
                 f.close()
             except (IOError, OSError):
                 # ignore these
@@ -2199,10 +2211,24 @@
         
         cfgFile = os.path.join(repodir, self.adminDir, "hgrc")
         if not os.path.exists(cfgFile):
+            # open dialog to enter the initial data
+            from .HgRepoConfigDataDialog import HgRepoConfigDataDialog
+            dlg = HgRepoConfigDataDialog()
+            if dlg.exec_() == QDialog.Accepted:
+                createContents = True
+                defaultUrl, defaultPushUrl = dlg.getData()
+            else:
+                createContents = False
             try:
-                # TODO: open a dialog to enter the basic data
-                # default and default-push
                 cfg = open(cfgFile, "w")
+                if createContents:
+                    # write the data entered
+                    cfg.write("[paths]\n")
+                    if defaultUrl:
+                        cfg.write("default = {0}\n".format(defaultUrl))
+                    if defaultPushUrl:
+                        cfg.write("default-push = {0}\n".format(
+                            defaultPushUrl))
                 cfg.close()
                 self.__monitorRepoIniFile(repodir)
             except IOError:

eric ide

mercurial