changeset 10378:e1401c74572f

subrepo: change default path in hgrc of subrepo after cloning Previous behavior was to put in the cloned subrepos the path found in the original main repo. However it isn't valid for relative path and it seems more logical to reference instead the subrepos working copy path of the original main repo.
author Saint Germain <saintger@gmail.com>
date Sat, 06 Feb 2010 19:14:37 +0100
parents 04e1e6743809
children a7df048b6a0d
files mercurial/subrepo.py tests/test-subrepo tests/test-subrepo.out
diffstat 3 files changed, 36 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/subrepo.py	Sun Feb 07 15:31:53 2010 +0100
+++ b/mercurial/subrepo.py	Sat Feb 06 19:14:37 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:31:53 2010 +0100
+++ b/tests/test-subrepo	Sat Feb 06 19:14:37 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:31:53 2010 +0100
+++ b/tests/test-subrepo.out	Sat Feb 06 19:14:37 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