Commits

Steve Borho  committed 1113418

thgconfig: try other filenames in rcpath when creating a config file

In some corporate environments, %USERPROFILE% may not be writeable but perhaps
%HOME% is.

Fixes #610

  • Participants
  • Parent commits 778b2ea
  • Branches stable

Comments (0)

Files changed (1)

File tortoisehg/hgtk/thgconfig.py

             if os.path.exists(fn):
                 break
         else:
-            fn = rcpath[0]
-            f = open(fn, 'w')
-            f.write(_('# Generated by tortoisehg-config\n'))
-            f.close()
+            for fn in rcpath:
+                # Try to create a file from rcpath
+                try:
+                    f = open(fn, 'w')
+                    f.write(_('# Generated by tortoisehg-config\n'))
+                    f.close()
+                    break
+                except (IOError, OSError):
+                    pass
         self.fn = fn
         try:
             import iniparse