share: create 'hgrc' using an opener, like clone
authorDan Villiom Podlaski Christiansen <danchr@gmail.com>
Sun, 01 May 2011 18:43:20 +0200
changeset 14156 839086b25c36
parent 14155 921683f14ad7
child 14157 a8f136f430da
share: create 'hgrc' using an opener, like clone
mercurial/hg.py
--- a/mercurial/hg.py	Sun May 01 19:51:28 2011 +0200
+++ b/mercurial/hg.py	Sun May 01 18:43:20 2011 +0200
@@ -146,13 +146,14 @@
     file(os.path.join(roothg, 'requires'), 'w').write(requirements)
     file(os.path.join(roothg, 'sharedpath'), 'w').write(sharedpath)
 
+    r = repository(ui, root)
+
     default = srcrepo.ui.config('paths', 'default')
     if default:
-        f = file(os.path.join(roothg, 'hgrc'), 'w')
-        f.write('[paths]\ndefault = %s\n' % default)
-        f.close()
-
-    r = repository(ui, root)
+        fp = r.opener("hgrc", "w", text=True)
+        fp.write("[paths]\n")
+        fp.write("default = %s\n" % default)
+        fp.close()
 
     if update:
         r.ui.status(_("updating working directory\n"))