changeset 8815:e87b0fc4750b

subrepo: basic push support
author Matt Mackall <mpm@selenic.com>
date Mon, 15 Jun 2009 02:46:20 -0500
parents ab668c92a036
children a7c4eb0cc0ed
files mercurial/commands.py mercurial/subrepo.py
diffstat 2 files changed, 23 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Mon Jun 15 02:45:38 2009 -0500
+++ b/mercurial/commands.py	Mon Jun 15 02:46:20 2009 -0500
@@ -2289,6 +2289,13 @@
     ui.status(_('pushing to %s\n') % url.hidepassword(dest))
     if revs:
         revs = [repo.lookup(rev) for rev in revs]
+
+    # push subrepos depth-first for coherent ordering
+    c = repo['']
+    subs = c.substate # only repos that are committed
+    for s in sorted(subs):
+        c.sub(s).push(opts.get('force'))
+
     r = repo.push(other, opts.get('force'), revs=revs)
     return r == 0
 
--- a/mercurial/subrepo.py	Mon Jun 15 02:45:38 2009 -0500
+++ b/mercurial/subrepo.py	Mon Jun 15 02:46:20 2009 -0500
@@ -102,12 +102,14 @@
     # record merged .hgsubstate
     writestate(repo, sm)
 
-def _abssource(repo):
+def _abssource(repo, push=False):
     if hasattr(repo, '_subparent'):
         source = repo._subsource
         if source.startswith('/') or '://' in source:
             return source
         return os.path.join(_abssource(repo._subparent), repo._subsource)
+    if push and repo.ui.config('paths', 'default-push'):
+        return repo.ui.config('paths', 'default-push', repo.root)
     return repo.ui.config('paths', 'default', repo.root)
 
 def subrepo(ctx, path):
@@ -127,7 +129,6 @@
 
 class hgsubrepo(object):
     def __init__(self, ctx, path, state):
-        self._parent = ctx
         self._path = path
         self._state = state
         r = ctx._repo
@@ -176,3 +177,16 @@
 
     def merge(self, state):
         hg.merge(self._repo, state[1], remind=False)
+
+    def push(self, force):
+        # push subrepos depth-first for coherent ordering
+        c = self._repo['']
+        subs = c.substate # only repos that are committed
+        for s in sorted(subs):
+            c.sub(s).push(force)
+
+        self._repo.ui.status(_('pushing subrepo %s\n') % self._path)
+        dsturl = _abssource(self._repo, True)
+        other = hg.repository(self._repo.ui, dsturl)
+        self._repo.push(other, force)
+