Commit 4f6727a6 authored by Hrvoje Ribicic's avatar Hrvoje Ribicic

Merge branch 'stable-2.9' into stable-2.10

* stable-2.9
  (no changes)

* stable-2.8:
  Fix QA patching functionality
Signed-off-by: default avatarHrvoje Ribicic <riba@google.com>
Reviewed-by: default avatarPetr Pudlak <pudlak@google.com>
parents 21698e49 b9566a29
......@@ -297,7 +297,7 @@ class _QaConfig(object):
"""Applies a single patch.
@type data: dict (deserialized json)
@param data: The QA configuration
@param data: The QA configuration to modify
@type patch_module: module
@param patch_module: The json patch module, loaded dynamically
@type patches: dict of string to dict
......@@ -305,15 +305,13 @@ class _QaConfig(object):
@type patch_path: string
@param patch_path: The path to the patch, relative to the QA directory
@return: The modified configuration data.
"""
patch_content = patches[patch_path]
print qa_logging.FormatInfo("Applying patch %s" % patch_path)
if not patch_content and patch_path != _QA_DEFAULT_PATCH:
print qa_logging.FormatWarning("The patch %s added by the user is empty" %
patch_path)
data = patch_module.apply_patch(data, patch_content)
patch_module.apply_patch(data, patch_content, in_place=True)
@staticmethod
def ApplyPatches(data, patch_module, patches):
......@@ -326,14 +324,12 @@ class _QaConfig(object):
top-level QA directory is applied.
@type data: dict (deserialized json)
@param data: The QA configuration
@param data: The QA configuration to modify
@type patch_module: module
@param patch_module: The json patch module, loaded dynamically
@type patches: dict of string to dict
@param patches: The dictionary of patch path to content
@return: The modified configuration data.
"""
ordered_patches = []
order_path = os.path.join(_QA_BASE_PATH, _QA_PATCH_DIR,
......@@ -364,8 +360,6 @@ class _QaConfig(object):
if _QA_DEFAULT_PATCH in patches:
_QaConfig.ApplyPatch(data, patch_module, patches, _QA_DEFAULT_PATCH)
return data
@classmethod
def Load(cls, filename):
"""Loads a configuration file and produces a configuration object.
......@@ -384,7 +378,7 @@ class _QaConfig(object):
# Try to use the module only if there is a non-empty patch present
if any(patches.values()):
mod = __import__("jsonpatch", fromlist=[])
data = _QaConfig.ApplyPatches(data, mod, patches)
_QaConfig.ApplyPatches(data, mod, patches)
except IOError:
pass
except ImportError:
......
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