changeset 13460:64bb8e586a92 stable

subrepo: expand relative sources for git subrepos
author Eric Eisner <ede@mit.edu>
date Tue, 22 Feb 2011 15:11:10 -0500
parents acbe171c8fbe
children 81af2040b586
files mercurial/subrepo.py tests/test-subrepo-git.t
diffstat 2 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/subrepo.py	Tue Feb 22 16:31:01 2011 +0100
+++ b/mercurial/subrepo.py	Tue Feb 22 15:11:10 2011 -0500
@@ -659,6 +659,7 @@
         self._path = path
         self._relpath = os.path.join(reporelpath(ctx._repo), path)
         self._abspath = ctx._repo.wjoin(path)
+        self._subparent = ctx._repo
         self._ui = ctx._repo.ui
 
     def _gitcommand(self, commands, env=None, stream=False):
@@ -751,10 +752,14 @@
                          (remote, ref.split('/', 2)[2])] = b
         return tracking
 
+    def _abssource(self, source):
+        self._subsource = source
+        return _abssource(self)
+
     def _fetch(self, source, revision):
         if not os.path.exists(os.path.join(self._abspath, '.git')):
             self._ui.status(_('cloning subrepo %s\n') % self._relpath)
-            self._gitnodir(['clone', source, self._abspath])
+            self._gitnodir(['clone', self._abssource(source), self._abspath])
         if self._githavelocally(revision):
             return
         self._ui.status(_('pulling subrepo %s\n') % self._relpath)
@@ -763,7 +768,7 @@
         if self._githavelocally(revision):
             return
         # then try from known subrepo source
-        self._gitcommand(['fetch', source])
+        self._gitcommand(['fetch', self._abssource(source)])
         if not self._githavelocally(revision):
             raise util.Abort(_("revision %s does not exist in subrepo %s\n") %
                                (revision, self._relpath))
--- a/tests/test-subrepo-git.t	Tue Feb 22 16:31:01 2011 +0100
+++ b/tests/test-subrepo-git.t	Tue Feb 22 15:11:10 2011 -0500
@@ -305,6 +305,15 @@
   f
   g
 
+relative source expansion
+
+  $ cd ..
+  $ mkdir d
+  $ hg clone t d/t
+  updating to branch default
+  cloning subrepo s
+  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
 Check hg update --clean
   $ cd $TESTTMP/ta
   $ echo  > s/g