subrepo: initialize subrepo relative default paths relative to their root stable
authorMads Kiilerich <mads@kiilerich.com>
Fri, 10 Dec 2010 01:30:16 +0100
branchstable
changeset 13105 2245fcd0e160
parent 13103 6e79a3bb8c79
child 13117 594ed85b6a3f
child 13122 4a13ca2c21ce
child 13123 2506658c3927
subrepo: initialize subrepo relative default paths relative to their root
mercurial/subrepo.py
tests/test-subrepo-relative-path.t
--- a/mercurial/subrepo.py	Tue Dec 07 20:03:04 2010 +1100
+++ b/mercurial/subrepo.py	Fri Dec 10 01:30:16 2010 +0100
@@ -333,6 +333,8 @@
 
             def addpathconfig(key, value):
                 if value:
+                    if not os.path.isabs(value):
+                        value = os.path.relpath(os.path.abspath(value), root)
                     fp.write('%s = %s\n' % (key, value))
                     self._repo.ui.setconfig('paths', key, value)
 
--- a/tests/test-subrepo-relative-path.t	Tue Dec 07 20:03:04 2010 +1100
+++ b/tests/test-subrepo-relative-path.t	Fri Dec 10 01:30:16 2010 +0100
@@ -67,3 +67,58 @@
    revision 863c1745b441bd97a8c4a096e87793073f4fb215
 
   $ "$TESTDIR/killdaemons.py"
+
+
+Create repo with nested relative subrepos
+
+  $ hg init r1
+  $ hg init r1/sub
+  $ echo sub = sub > r1/.hgsub
+  $ hg add --cwd r1 .hgsub
+  $ hg init r1/sub/subsub
+  $ echo subsub = subsub > r1/sub/.hgsub
+  $ hg add --cwd r1/sub .hgsub
+  $ echo c1 > r1/sub/subsub/f
+  $ hg add --cwd r1/sub/subsub f
+  $ hg ci --cwd r1 -m0
+  committing subrepository sub
+  committing subrepository sub/subsub
+
+Ensure correct relative paths are used when pulling
+
+  $ hg init r2
+  $ cd r2/
+  $ hg pull -u ../r1
+  pulling from ../r1
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 2 changes to 2 files
+  pulling subrepo sub from ../r1/sub
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 2 changes to 2 files
+  pulling subrepo sub/subsub from ../r1/sub/subsub
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cd ..
+
+Verify subrepo default paths were set correctly
+
+  $ hg -R r2/sub paths
+  default = $TESTTMP/r1/sub
+  $ cat r2/sub/.hg/hgrc
+  [paths]
+  default = ../../r1/sub
+  $ hg -R r2/sub/subsub paths
+  default = $TESTTMP/r1/sub/subsub
+  $ cat r2/sub/subsub/.hg/hgrc
+  [paths]
+  default = ../../../r1/sub/subsub