exchange: perform stream clone with clone bundle with --uncompressed
Previously, `hg clone --uncompressed` would always clone from the
origin server, even if a streaming clone bundle were available.
With this change, we invoke the clone bundle mechanism before the
stream clone mechanism, giving clone bundles the opportunity to
handle --uncompressed (which is mapped to pullop.streamclonepreferred).
The clone bundle filtering code now filters out entries that aren't
stream clones when a stream clone is requested. If a stream clone
clone bundle entry is present, it will be used. Otherwise, the client
will fall back to a server-based streaming clone.
.. feature::
`hg clone --uncompressed` uses clone bundles when possible
Differential Revision: https://phab.mercurial-scm.org/D833
--- a/mercurial/exchange.py Thu Sep 28 12:17:30 2017 +0200
+++ b/mercurial/exchange.py Thu Sep 28 15:24:54 2017 +0100
@@ -1239,10 +1239,10 @@
wlock = pullop.repo.wlock()
lock = pullop.repo.lock()
pullop.trmanager = transactionmanager(repo, 'pull', remote.url())
- streamclone.maybeperformlegacystreamclone(pullop)
# This should ideally be in _pullbundle2(). However, it needs to run
# before discovery to avoid extra work.
_maybeapplyclonebundle(pullop)
+ streamclone.maybeperformlegacystreamclone(pullop)
_pulldiscovery(pullop)
if pullop.canusebundle2:
_pullbundle2(pullop)
@@ -1864,7 +1864,9 @@
'falling back to regular clone\n'))
return
- entries = filterclonebundleentries(repo, entries)
+ entries = filterclonebundleentries(
+ repo, entries, streamclonerequested=pullop.streamclonerequested)
+
if not entries:
# There is a thundering herd concern here. However, if a server
# operator doesn't advertise bundles appropriate for its clients,
@@ -1933,7 +1935,7 @@
return m
-def filterclonebundleentries(repo, entries):
+def filterclonebundleentries(repo, entries, streamclonerequested=False):
"""Remove incompatible clone bundle manifest entries.
Accepts a list of entries parsed with ``parseclonebundlesmanifest``
@@ -1948,7 +1950,15 @@
spec = entry.get('BUNDLESPEC')
if spec:
try:
- parsebundlespec(repo, spec, strict=True)
+ comp, version, params = parsebundlespec(repo, spec, strict=True)
+
+ # If a stream clone was requested, filter out non-streamclone
+ # entries.
+ if streamclonerequested and (comp != 'UN' or version != 's1'):
+ repo.ui.debug('filtering %s because not a stream clone\n' %
+ entry['URL'])
+ continue
+
except error.InvalidBundleSpecification as e:
repo.ui.debug(str(e) + '\n')
continue
@@ -1956,6 +1966,12 @@
repo.ui.debug('filtering %s because unsupported bundle '
'spec: %s\n' % (entry['URL'], str(e)))
continue
+ # If we don't have a spec and requested a stream clone, we don't know
+ # what the entry is so don't attempt to apply it.
+ elif streamclonerequested:
+ repo.ui.debug('filtering %s because cannot determine if a stream '
+ 'clone bundle\n' % entry['URL'])
+ continue
if 'REQUIRESNI' in entry and not sslutil.hassni:
repo.ui.debug('filtering %s because SNI not supported\n' %
--- a/tests/test-clonebundles.t Thu Sep 28 12:17:30 2017 +0200
+++ b/tests/test-clonebundles.t Thu Sep 28 15:24:54 2017 +0100
@@ -441,6 +441,8 @@
> EOF
$ hg clone -U --uncompressed http://localhost:$HGPORT uncompressed-gzip
+ no compatible clone bundles available on server; falling back to regular clone
+ (you may want to report this to the server operator)
streaming all changes
4 files to transfer, 613 bytes of data
transferred 613 bytes in * seconds (*) (glob)
@@ -454,6 +456,8 @@
> EOF
$ hg clone -U --uncompressed http://localhost:$HGPORT uncompressed-no-bundlespec
+ no compatible clone bundles available on server; falling back to regular clone
+ (you may want to report this to the server operator)
streaming all changes
4 files to transfer, 613 bytes of data
transferred 613 bytes in * seconds (*) (glob)
@@ -468,9 +472,10 @@
> EOF
$ hg clone -U --uncompressed http://localhost:$HGPORT uncompressed-gzip-packed
- streaming all changes
+ applying clone bundle from http://localhost:$HGPORT1/packed.hg
4 files to transfer, 613 bytes of data
transferred 613 bytes in * seconds (*) (glob)
+ finished applying clone bundle
searching for changes
no changes found
@@ -482,9 +487,10 @@
> EOF
$ hg clone -U --uncompressed http://localhost:$HGPORT uncompressed-gzip-packed-requirements
- streaming all changes
+ applying clone bundle from http://localhost:$HGPORT1/packed.hg
4 files to transfer, 613 bytes of data
transferred 613 bytes in * seconds (*) (glob)
+ finished applying clone bundle
searching for changes
no changes found
@@ -496,6 +502,8 @@
> EOF
$ hg clone -U --uncompressed http://localhost:$HGPORT uncompressed-gzip-packed-unsupported-requirements
+ no compatible clone bundles available on server; falling back to regular clone
+ (you may want to report this to the server operator)
streaming all changes
4 files to transfer, 613 bytes of data
transferred 613 bytes in * seconds (*) (glob)