[PATCH] subrepo: expand relative sources for git subrepos

Eric Eisner ede at MIT.EDU
Tue Feb 22 14:12:44 CST 2011


# HG changeset patch
# User Eric Eisner <ede at mit.edu>
# Date 1298405470 18000
# Branch stable
# Node ID 64bb8e586a92a5e5f2f5edf5843ac3ffc85f4495
# Parent  acbe171c8fbe9b789057f84fb962a9c2a966a787
subrepo: expand relative sources for git subrepos

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -659,6 +659,7 @@ class gitsubrepo(abstractsubrepo):
         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 @@ class gitsubrepo(abstractsubrepo):
                          (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 @@ class gitsubrepo(abstractsubrepo):
         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))
diff --git a/tests/test-subrepo-git.t b/tests/test-subrepo-git.t
--- a/tests/test-subrepo-git.t
+++ b/tests/test-subrepo-git.t
@@ -305,6 +305,15 @@ nested archive
   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


More information about the Mercurial-devel mailing list