--- a/mercurial/subrepo.py Sun Feb 07 15:57:16 2010 +0100
+++ b/mercurial/subrepo.py Sun Feb 07 16:04:42 2010 +0100
@@ -183,7 +183,8 @@
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' % state[0])
+ f.write('[paths]\ndefault = %s\n' % os.path.join(
+ _abssource(ctx._repo), path))
f.close()
self._repo._subparent = r
self._repo._subsource = state[0]
--- a/tests/test-subrepo Sun Feb 07 15:57:16 2010 +0100
+++ b/tests/test-subrepo Sun Feb 07 16:04:42 2010 +0100
@@ -160,5 +160,27 @@
hg up 5
hg merge 4 # try to merge default into br again
+cd ..
+
+echo % test repository cloning
+mkdir mercurial mercurial2
+hg init nested_absolute
+echo test > nested_absolute/foo
+hg -R nested_absolute add
+hg -R nested_absolute ci -mtest
+cd mercurial
+hg init nested_relative
+echo test2 > nested_relative/foo2
+hg -R nested_relative add
+hg -R nested_relative ci -mtest2
+hg init main
+echo nested_relative = ../nested_relative > main/.hgsub
+echo nested_absolute = $PWD/nested_absolute >> main/.hgsub
+hg -R main add
+hg -R main ci -m "add subrepos"
+cd ..
+hg clone mercurial/main mercurial2/main
+cat mercurial2/main/nested_absolute/.hg/hgrc mercurial2/main/nested_relative/.hg/hgrc | sed "s:${PWD}:/tmp:"
+rm -rf mercurial mercurial2
exit 0
--- a/tests/test-subrepo.out Sun Feb 07 15:57:16 2010 +0100
+++ b/tests/test-subrepo.out Sun Feb 07 16:04:42 2010 +0100
@@ -243,3 +243,15 @@
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
+% test repository cloning
+adding nested_absolute/foo
+adding nested_relative/foo2
+adding main/.hgsub
+committing subrepository nested_relative
+committing subrepository nested_absolute
+updating to branch default
+2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+[paths]
+default = /tmp/mercurial/main/nested_absolute
+[paths]
+default = /tmp/mercurial/main/nested_relative