Mercurial > hg
comparison tests/hghave.py @ 30559:d83ca854fa21
ui: factor out ui.load() to create a ui without loading configs (API)
This allows us to write doctests depending on a ui object, but not on global
configs.
ui.load() is a class method so we can do wsgiui.load(). All ui() calls but
for doctests are replaced with ui.load(). Some of them could be changed to
not load configs later.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 22 Oct 2016 14:35:10 +0900 |
parents | de48d3a0573a |
children | aa797bd54f44 |
comparison
equal
deleted
inserted
replaced
30557:cbeb54ec0481 | 30559:d83ca854fa21 |
---|---|
447 return False | 447 return False |
448 | 448 |
449 @check("defaultcacerts", "can verify SSL certs by system's CA certs store") | 449 @check("defaultcacerts", "can verify SSL certs by system's CA certs store") |
450 def has_defaultcacerts(): | 450 def has_defaultcacerts(): |
451 from mercurial import sslutil, ui as uimod | 451 from mercurial import sslutil, ui as uimod |
452 ui = uimod.ui() | 452 ui = uimod.ui.load() |
453 return sslutil._defaultcacerts(ui) or sslutil._canloaddefaultcerts | 453 return sslutil._defaultcacerts(ui) or sslutil._canloaddefaultcerts |
454 | 454 |
455 @check("defaultcacertsloaded", "detected presence of loaded system CA certs") | 455 @check("defaultcacertsloaded", "detected presence of loaded system CA certs") |
456 def has_defaultcacertsloaded(): | 456 def has_defaultcacertsloaded(): |
457 import ssl | 457 import ssl |
460 if not has_defaultcacerts(): | 460 if not has_defaultcacerts(): |
461 return False | 461 return False |
462 if not has_sslcontext(): | 462 if not has_sslcontext(): |
463 return False | 463 return False |
464 | 464 |
465 ui = uimod.ui() | 465 ui = uimod.ui.load() |
466 cafile = sslutil._defaultcacerts(ui) | 466 cafile = sslutil._defaultcacerts(ui) |
467 ctx = ssl.create_default_context() | 467 ctx = ssl.create_default_context() |
468 if cafile: | 468 if cafile: |
469 ctx.load_verify_locations(cafile=cafile) | 469 ctx.load_verify_locations(cafile=cafile) |
470 else: | 470 else: |