Implementing clone -r, which clones all changesets needed to reach a
particular revision.
--- a/mercurial/commands.py Fri Oct 07 19:49:25 2005 -0700
+++ b/mercurial/commands.py Fri Oct 07 19:51:09 2005 -0700
@@ -627,7 +627,7 @@
copy = False
if other.dev() != -1:
abspath = os.path.abspath(source)
- if not opts['pull']:
+ if not opts['pull'] and not opts['rev']:
copy = True
if copy:
@@ -655,7 +655,10 @@
else:
repo = hg.repository(ui, dest, create=1)
- repo.pull(other)
+ rev = None
+ if opts['rev']:
+ rev = [other.lookup(opts['rev'])]
+ repo.pull(other, heads = rev)
f = repo.opener("hgrc", "w", text=True)
f.write("[paths]\n")
@@ -1782,6 +1785,7 @@
(clone,
[('U', 'noupdate', None, 'skip update after cloning'),
('e', 'ssh', "", 'ssh command'),
+ ('r', 'rev', "", 'only clone changesets needed to create revision'),
('', 'pull', None, 'use pull protocol to copy metadata'),
('', 'remotecmd', "", 'remote hg command')],
'hg clone [OPTION]... SOURCE [DEST]'),
--- a/mercurial/localrepo.py Fri Oct 07 19:49:25 2005 -0700
+++ b/mercurial/localrepo.py Fri Oct 07 19:51:09 2005 -0700
@@ -850,7 +850,7 @@
# this is the set of all roots we have to push
return subset
- def pull(self, remote):
+ def pull(self, remote, heads = None):
lock = self.lock()
# if we have an empty repo, fetch everything
@@ -864,7 +864,10 @@
self.ui.status("no changes found\n")
return 1
- cg = remote.changegroup(fetch)
+ if heads is None:
+ cg = remote.changegroup(fetch)
+ else:
+ cg = remote.changegroupsubset(fetch, heads)
return self.addchangegroup(cg)
def push(self, remote, force=False):