[PATCH] subrepo: pull subrepos recursively, and support pull from clones (issue2024)
Pradeepkumar Gayam
in3xes at gmail.com
Sat Jul 10 17:53:35 CDT 2010
# HG changeset patch
# User Pradeepkumar Gayam <in3xes at gmail.com>
# Date 1278801299 -19800
# Node ID ed3ea5d08f64b0b4ea94353ca42cfa6f07e8f38f
# Parent f4eddec324b755a45ea71570c7c8dc63bcbdfc1a
subrepo: pull subrepos recursively, and support pull from clones (issue2024)
diff -r f4eddec324b7 -r ed3ea5d08f64 mercurial/commands.py
--- a/mercurial/commands.py Fri Jul 09 14:21:45 2010 +0200
+++ b/mercurial/commands.py Sun Jul 11 04:04:59 2010 +0530
@@ -2798,6 +2798,19 @@
raise util.Abort(err)
modheads = repo.pull(other, heads=revs, force=opts.get('force'))
+
+ if opts.get('subrepo'):
+ c = repo[repo.changelog.node(len(repo)-1)]
+ if '.hgsubstate' in c.manifest():
+ subrepos = c.substate
+ for s in sorted(subrepos):
+ try:
+ c.sub(s).pull(opts.get('force'), source)
+ except:
+ pass
+ else:
+ ui.status(_('No subrepos present'))
+
if checkout:
checkout = str(repo.changelog.rev(other.lookup(checkout)))
return postincoming(ui, repo, modheads, opts.get('update'), checkout)
@@ -4308,6 +4321,8 @@
_('update to new branch head if changesets were pulled')),
('f', 'force', None,
_('run even when remote repository is unrelated')),
+ ('s', 'subrepo', None,
+ _('pull subrepos recursively')),
('r', 'rev', [],
_('a remote changeset intended to be added'), _('REV')),
('b', 'branch', [],
diff -r f4eddec324b7 -r ed3ea5d08f64 mercurial/subrepo.py
--- a/mercurial/subrepo.py Fri Jul 09 14:21:45 2010 +0200
+++ b/mercurial/subrepo.py Sun Jul 11 04:04:59 2010 +0530
@@ -138,12 +138,13 @@
parent = parent._subparent
return sub._repo.root[len(parent.root)+1:]
-def _abssource(repo, push=False):
+def _abssource(repo, push=False, parent=None):
if hasattr(repo, '_subparent'):
source = repo._subsource
if source.startswith('/') or '://' in source:
return source
- parent = _abssource(repo._subparent, push)
+ if parent is None:
+ parent = _abssource(repo._subparent, push)
if '://' in parent:
if parent[-1] == '/':
parent = parent[:-1]
@@ -284,6 +285,24 @@
other = hg.repository(self._repo.ui, dsturl)
return self._repo.push(other, force)
+ def pull(self, force, source=None):
+ srcurl = _abssource(self._repo, parent=source)
+ self._repo.ui.status(_('pulling from subrepo %s to %s\n') %
+ (srcurl, relpath(self)))
+ other = hg.repository(self._repo.ui, srcurl)
+ heads = self._repo.pull(other, force=force)
+
+ c = self._repo[self._repo.changelog.node(len(self._repo)-1)]
+ if '.hgsubstate' in c.manifest():
+ subrepos = c.substate
+ for s in sorted(subrepos):
+ try:
+ c.sub(s).pull(force, srcurl)
+ except:
+ pass
+ else:
+ return
+
class svnsubrepo(object):
def __init__(self, ctx, path, state):
self._path = path
More information about the Mercurial-devel
mailing list