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

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