changeset 10667:b7e528212828 stable

merge with stable
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Sat, 13 Mar 2010 16:44:52 +0100
parents 4c50a90b90fc (diff) 9602fc4e6914 (current diff)
children 181cbb23572e
files
diffstat 1 files changed, 18 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/subrepo.py	Sat Mar 13 16:19:28 2010 +0100
+++ b/mercurial/subrepo.py	Sat Mar 13 16:44:52 2010 +0100
@@ -131,7 +131,7 @@
         source = repo._subsource
         if source.startswith('/') or '://' in source:
             return source
-        parent = _abssource(repo._subparent)
+        parent = _abssource(repo._subparent, push)
         if '://' in parent:
             if parent[-1] == '/':
                 parent = parent[:-1]
@@ -177,24 +177,32 @@
         self._state = state
         r = ctx._repo
         root = r.wjoin(path)
-        if os.path.exists(os.path.join(root, '.hg')):
-            self._repo = hg.repository(r.ui, root)
-        else:
+        create = False
+        if not os.path.exists(os.path.join(root, '.hg')):
+            create = True
             util.makedirs(root)
-            self._repo = hg.repository(r.ui, root, create=True)
-            f = file(os.path.join(root, '.hg', 'hgrc'), 'w')
-            f.write('[paths]\ndefault = %s\n' % os.path.join(
-                _abssource(ctx._repo), path))
-            f.close()
+        self._repo = hg.repository(r.ui, root, create=create)
         self._repo._subparent = r
         self._repo._subsource = state[0]
 
+        if create:
+            fp = self._repo.opener("hgrc", "w", text=True)
+            fp.write('[paths]\n')
+
+            def addpathconfig(key, value):
+                fp.write('%s = %s\n' % (key, value))
+                self._repo.ui.setconfig('paths', key, value)
+
+            defpath = os.path.join(_abssource(ctx._repo), path)
+            addpathconfig('default', defpath)
+            fp.close()
+
     def dirty(self):
         r = self._state[1]
         if r == '':
             return True
         w = self._repo[None]
-        if w.p1() != self._repo[r]: # version checked out changed
+        if w.p1() != self._repo[r]: # version checked out change
             return True
         return w.dirty() # working directory changed