##// END OF EJS Templates
clonebundles: filter out invalid schemes instead of failing on them...
Mathias De Mare -
r51435:7b723217 stable
parent child Browse files
Show More
@@ -24,6 +24,11 b' from .utils import stringutil'
24 urlreq = util.urlreq
24 urlreq = util.urlreq
25
25
26 CB_MANIFEST_FILE = b'clonebundles.manifest'
26 CB_MANIFEST_FILE = b'clonebundles.manifest'
27 SUPPORTED_CLONEBUNDLE_SCHEMES = [
28 b"http://",
29 b"https://",
30 b"largefile://",
31 ]
27
32
28
33
29 @attr.s
34 @attr.s
@@ -337,7 +342,9 b' def isstreamclonespec(bundlespec):'
337 return False
342 return False
338
343
339
344
340 def filterclonebundleentries(repo, entries, streamclonerequested=False):
345 def filterclonebundleentries(
346 repo, entries, streamclonerequested=False, pullbundles=False
347 ):
341 """Remove incompatible clone bundle manifest entries.
348 """Remove incompatible clone bundle manifest entries.
342
349
343 Accepts a list of entries parsed with ``parseclonebundlesmanifest``
350 Accepts a list of entries parsed with ``parseclonebundlesmanifest``
@@ -349,6 +356,16 b' def filterclonebundleentries(repo, entri'
349 """
356 """
350 newentries = []
357 newentries = []
351 for entry in entries:
358 for entry in entries:
359 url = entry.get(b'URL')
360 if not pullbundles and not any(
361 [url.startswith(scheme) for scheme in SUPPORTED_CLONEBUNDLE_SCHEMES]
362 ):
363 repo.ui.debug(
364 b'filtering %s because not a supported clonebundle scheme\n'
365 % url
366 )
367 continue
368
352 spec = entry.get(b'BUNDLESPEC')
369 spec = entry.get(b'BUNDLESPEC')
353 if spec:
370 if spec:
354 try:
371 try:
@@ -358,8 +375,7 b' def filterclonebundleentries(repo, entri'
358 # entries.
375 # entries.
359 if streamclonerequested and not isstreamclonespec(bundlespec):
376 if streamclonerequested and not isstreamclonespec(bundlespec):
360 repo.ui.debug(
377 repo.ui.debug(
361 b'filtering %s because not a stream clone\n'
378 b'filtering %s because not a stream clone\n' % url
362 % entry[b'URL']
363 )
379 )
364 continue
380 continue
365
381
@@ -369,7 +385,7 b' def filterclonebundleentries(repo, entri'
369 except error.UnsupportedBundleSpecification as e:
385 except error.UnsupportedBundleSpecification as e:
370 repo.ui.debug(
386 repo.ui.debug(
371 b'filtering %s because unsupported bundle '
387 b'filtering %s because unsupported bundle '
372 b'spec: %s\n' % (entry[b'URL'], stringutil.forcebytestr(e))
388 b'spec: %s\n' % (url, stringutil.forcebytestr(e))
373 )
389 )
374 continue
390 continue
375 # If we don't have a spec and requested a stream clone, we don't know
391 # If we don't have a spec and requested a stream clone, we don't know
@@ -377,14 +393,12 b' def filterclonebundleentries(repo, entri'
377 elif streamclonerequested:
393 elif streamclonerequested:
378 repo.ui.debug(
394 repo.ui.debug(
379 b'filtering %s because cannot determine if a stream '
395 b'filtering %s because cannot determine if a stream '
380 b'clone bundle\n' % entry[b'URL']
396 b'clone bundle\n' % url
381 )
397 )
382 continue
398 continue
383
399
384 if b'REQUIRESNI' in entry and not sslutil.hassni:
400 if b'REQUIRESNI' in entry and not sslutil.hassni:
385 repo.ui.debug(
401 repo.ui.debug(b'filtering %s because SNI not supported\n' % url)
386 b'filtering %s because SNI not supported\n' % entry[b'URL']
387 )
388 continue
402 continue
389
403
390 if b'REQUIREDRAM' in entry:
404 if b'REQUIREDRAM' in entry:
@@ -392,15 +406,14 b' def filterclonebundleentries(repo, entri'
392 requiredram = util.sizetoint(entry[b'REQUIREDRAM'])
406 requiredram = util.sizetoint(entry[b'REQUIREDRAM'])
393 except error.ParseError:
407 except error.ParseError:
394 repo.ui.debug(
408 repo.ui.debug(
395 b'filtering %s due to a bad REQUIREDRAM attribute\n'
409 b'filtering %s due to a bad REQUIREDRAM attribute\n' % url
396 % entry[b'URL']
397 )
410 )
398 continue
411 continue
399 actualram = repo.ui.estimatememory()
412 actualram = repo.ui.estimatememory()
400 if actualram is not None and actualram * 0.66 < requiredram:
413 if actualram is not None and actualram * 0.66 < requiredram:
401 repo.ui.debug(
414 repo.ui.debug(
402 b'filtering %s as it needs more than 2/3 of system memory\n'
415 b'filtering %s as it needs more than 2/3 of system memory\n'
403 % entry[b'URL']
416 % url
404 )
417 )
405 continue
418 continue
406
419
@@ -380,7 +380,7 b' def find_pullbundle(repo, proto, opts, c'
380 if not manifest:
380 if not manifest:
381 return None
381 return None
382 res = bundlecaches.parseclonebundlesmanifest(repo, manifest)
382 res = bundlecaches.parseclonebundlesmanifest(repo, manifest)
383 res = bundlecaches.filterclonebundleentries(repo, res)
383 res = bundlecaches.filterclonebundleentries(repo, res, pullbundles=True)
384 if not res:
384 if not res:
385 return None
385 return None
386 cl = repo.unfiltered().changelog
386 cl = repo.unfiltered().changelog
@@ -62,11 +62,16 b' Manifest file with invalid URL aborts'
62 Manifest file with URL with unknown scheme skips the URL
62 Manifest file with URL with unknown scheme skips the URL
63 $ echo 'weirdscheme://does.not.exist/bundle.hg' > server/.hg/clonebundles.manifest
63 $ echo 'weirdscheme://does.not.exist/bundle.hg' > server/.hg/clonebundles.manifest
64 $ hg clone http://localhost:$HGPORT unknown-scheme
64 $ hg clone http://localhost:$HGPORT unknown-scheme
65 applying clone bundle from weirdscheme://does.not.exist/bundle.hg (known-bad-output !)
65 no compatible clone bundles available on server; falling back to regular clone
66 error fetching bundle: unknown url type: weirdscheme (known-bad-output !)
66 (you may want to report this to the server operator)
67 abort: error applying bundle (known-bad-output !)
67 requesting all changes
68 (if this error persists, consider contacting the server operator or disable clone bundles via "--config ui.clonebundles=false") (known-bad-output !)
68 adding changesets
69 [255]
69 adding manifests
70 adding file changes
71 added 2 changesets with 2 changes to 2 files
72 new changesets 53245c60e682:aaff8d2ffbbf
73 updating to branch default
74 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
70
75
71 Server is not running aborts
76 Server is not running aborts
72
77
General Comments 0
You need to be logged in to leave comments. Login now