Commit 2bd95e18 authored by Marcin Kasperski's avatar Marcin Kasperski
Browse files

Migrated demandimport and logging support to meu. Functionally:

keyring logging now disables properly also on py2.6 (previously it
kept warning about nonworking logging)
parent b701b33b44cb
......@@ -111,15 +111,13 @@ def import_keyring():
until it is really needed. The routine below also works around various
demandimport-related problems.
"""
if 'keyring' in sys.modules:
return sys.modules['keyring']
# mercurial.demandimport incompatibility workaround.
# various keyring backends fail as they can't properly import helper
# modules (as demandimport modifies python import behaviour).
# If you get import errors with demandimport in backtrace, try
# guessing what to block and extending the list below.
from mercurial import demandimport
for blocked_module in [
mod, was_imported_now = meu.direct_import_ext(
"keyring", [
"gobject._gobject",
"configparser",
"json",
......@@ -136,38 +134,12 @@ def import_keyring():
"ctypes",
"secretstorage.exceptions",
"fs.opener",
]:
if blocked_module not in demandimport.ignore:
demandimport.ignore.append(blocked_module)
])
if was_imported_now:
# Shut up warning about uninitialized logging by keyring
meu.disable_logging("keyring")
return mod
# Various attempts to define is_demandimport_enabled
try:
# Since Mercurial 2.9.1
is_demandimport_enabled = demandimport.isenabled
except AttributeError:
def is_demandimport_enabled():
"""Checks whether demandimport is enabled at the moment"""
return __import__ == demandimport._demandimport
# Shut up warning about uninitialized logging for new keyring versions.
# But beware 2.6…
try:
import logging
logging.getLogger("keyring").addHandler(logging.NullHandler())
except: # pylint: disable=bare-except
pass
# Temporarily disable demandimport to make the need of extending
# the list above less likely.
if is_demandimport_enabled():
demandimport.disable()
try:
import keyring
finally:
demandimport.enable()
else:
import keyring
return keyring
#################################################################
# Actual implementation
......
......@@ -36,7 +36,7 @@ setup(
],
install_requires=[
'keyring>=0.3',
'mercurial_extension_utils>=1.0.0',
'mercurial_extension_utils>=1.1.0',
],
zip_safe=True,
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment