diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -959,6 +959,7 @@ def clone(ui, source, dest=None, **opts) ui.setconfig_remoteopts(**opts) hg.clone(ui, ui.expandpath(source), dest, pull=opts['pull'], + stream=opts['stream'], rev=opts['rev'], update=not opts['noupdate']) @@ -2850,6 +2851,7 @@ table = { ('r', 'rev', [], _('a changeset you would like to have after cloning')), ('', 'pull', None, _('use pull protocol to copy metadata')), + ('', 'stream', None, _('use streaming protocol (fast over LAN)')), ('e', 'ssh', '', _('specify ssh command to use')), ('', 'remotecmd', '', _('specify hg command to run on the remote side'))], diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -74,7 +74,8 @@ def repository(ui, path=None, create=0): scheme) return ctor(ui, path) -def clone(ui, source, dest=None, pull=False, rev=None, update=True): +def clone(ui, source, dest=None, pull=False, rev=None, update=True, + stream=False): """Make a copy of an existing repository. Create a copy of an existing repository in a new directory. The @@ -96,6 +97,8 @@ def clone(ui, source, dest=None, pull=Fa pull: always pull from source repository, even in local case + stream: stream from repository (fast over LAN, slow over WAN) + rev: revision to clone up to (implies pull=True) update: update working directory after clone completes, if @@ -179,7 +182,7 @@ def clone(ui, source, dest=None, pull=Fa revs = [src_repo.lookup(r) for r in rev] if dest_repo.local(): - dest_repo.clone(src_repo, heads=revs, pull=pull) + dest_repo.clone(src_repo, heads=revs, stream=stream) elif src_repo.local(): src_repo.push(dest_repo, revs=revs) else: diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -2225,9 +2225,8 @@ class localrepository(repo.repository): self.reload() return len(self.heads()) + 1 - def clone(self, remote, heads=[], pull=False): + def clone(self, remote, heads=[], stream=False): '''clone remote repository. - if possible, changes are streamed from remote server. keyword arguments: heads: list of revs to clone (forces use of pull) @@ -2240,7 +2239,7 @@ class localrepository(repo.repository): # and format flags on "stream" capability, and stream only if # compatible. - if not pull and not heads and remote.capable('stream'): + if stream and not heads and remote.capable('stream'): return self.stream_in(remote) return self.pull(remote, heads) diff --git a/tests/test-http b/tests/test-http --- a/tests/test-http +++ b/tests/test-http @@ -12,7 +12,7 @@ cat hg.pid >> $DAEMON_PIDS cd .. echo % clone via stream -http_proxy= hg clone http://localhost:20059/ copy 2>&1 | \ +http_proxy= hg clone --stream http://localhost:20059/ copy 2>&1 | \ sed -e 's/[0-9][0-9.]*/XXX/g' cd copy hg verify @@ -20,6 +20,6 @@ hg verify cd .. echo % clone via pull -http_proxy= hg clone --pull http://localhost:20059/ copy-pull +http_proxy= hg clone http://localhost:20059/ copy-pull cd copy-pull hg verify diff --git a/tests/test-http-proxy b/tests/test-http-proxy --- a/tests/test-http-proxy +++ b/tests/test-http-proxy @@ -14,26 +14,26 @@ cat proxy.pid >> $DAEMON_PIDS sleep 2 echo %% url for proxy, stream -http_proxy=http://localhost:20060/ hg --config http_proxy.always=True clone http://localhost:20059/ b | \ +http_proxy=http://localhost:20060/ hg --config http_proxy.always=True clone --stream http://localhost:20059/ b | \ sed -e 's/[0-9][0-9.]*/XXX/g' cd b hg verify cd .. echo %% url for proxy, pull -http_proxy=http://localhost:20060/ hg --config http_proxy.always=True clone --pull http://localhost:20059/ b-pull +http_proxy=http://localhost:20060/ hg --config http_proxy.always=True clone http://localhost:20059/ b-pull cd b-pull hg verify cd .. echo %% host:port for proxy -http_proxy=localhost:20060 hg clone --pull --config http_proxy.always=True http://localhost:20059/ c +http_proxy=localhost:20060 hg clone --config http_proxy.always=True http://localhost:20059/ c echo %% proxy url with user name and password -http_proxy=http://user:passwd@localhost:20060 hg clone --pull --config http_proxy.always=True http://localhost:20059/ d +http_proxy=http://user:passwd@localhost:20060 hg clone --config http_proxy.always=True http://localhost:20059/ d echo %% url with user name and password -http_proxy=http://user:passwd@localhost:20060 hg clone --pull --config http_proxy.always=True http://user:passwd@localhost:20059/ e +http_proxy=http://user:passwd@localhost:20060 hg clone --config http_proxy.always=True http://user:passwd@localhost:20059/ e echo %% bad host:port for proxy http_proxy=localhost:20061 hg clone --config http_proxy.always=True http://localhost:20059/ f diff --git a/tests/test-ssh b/tests/test-ssh --- a/tests/test-ssh +++ b/tests/test-ssh @@ -31,14 +31,14 @@ hg ci -A -m "init" -d "1000000 0" foo cd .. echo "# clone remote via stream" -hg clone -e ./dummyssh ssh://user@dummy/remote local-stream 2>&1 | \ +hg clone -e ./dummyssh --stream ssh://user@dummy/remote local-stream 2>&1 | \ sed -e 's/[0-9][0-9.]*/XXX/g' cd local-stream hg verify cd .. echo "# clone remote via pull" -hg clone -e ./dummyssh --pull ssh://user@dummy/remote local +hg clone -e ./dummyssh ssh://user@dummy/remote local echo "# verify" cd local