diff options
author | bst-marge-bot <marge-bot@buildstream.build> | 2019-05-02 15:25:36 +0000 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-05-02 15:25:36 +0000 |
commit | 0b5f7bbc3c517d904d170e8770754c85d15cd089 (patch) | |
tree | 431745b808af08a3d2d9034da6f2df5acad92e3d | |
parent | bccb4f15a784a80561c32665ced44554dbd9b5ce (diff) | |
parent | 6961eec10ab6d375978713ccde83dc12e6ef86db (diff) | |
download | buildstream-0b5f7bbc3c517d904d170e8770754c85d15cd089.tar.gz |
Merge branch 'danielsilverstone-ct/track-update' into 'master'
_yaml.py, source.py: Fix tracking of refs inside conditions
See merge request BuildStream/buildstream!1324
-rw-r--r-- | buildstream/_yaml.py | 11 | ||||
-rw-r--r-- | buildstream/source.py | 7 |
2 files changed, 16 insertions, 2 deletions
diff --git a/buildstream/_yaml.py b/buildstream/_yaml.py index c1297e9dd..cdab4269e 100644 --- a/buildstream/_yaml.py +++ b/buildstream/_yaml.py @@ -1204,18 +1204,27 @@ def assert_symbol_name(provenance, symbol_name, purpose, *, allow_dashes=True): # This is typically used when trying to walk a path to a given node # for the purpose of then modifying a similar tree of objects elsewhere # +# If the key is provided, then we actually hunt for the node represented by +# target[key] and return its container, rather than hunting for target directly +# # Args: # node (Node): The node at the root of the tree to search # target (Node): The node you are looking for in that tree +# key (str): Optional string key within target node # # Returns: # (list): A path from `node` to `target` or None if `target` is not in the subtree -def node_find_target(node, target): +def node_find_target(node, target, *, key=None): assert type(node) is Node assert type(target) is Node + if key is not None: + target = target[0][key] path = [] if _walk_find_target(node, path, target): + if key: + # Remove key from end of path + path = path[:-1] return path return None diff --git a/buildstream/source.py b/buildstream/source.py index daf2cb27c..0c07dd41e 100644 --- a/buildstream/source.py +++ b/buildstream/source.py @@ -951,10 +951,15 @@ class Source(Plugin): provenance = _yaml.node_get_provenance(node) else: provenance = _yaml.node_get_provenance(node, key=key) + toplevel_node = provenance.toplevel # Get the path to whatever changed - path = _yaml.node_find_target(toplevel_node, node) + if action == 'add': + path = _yaml.node_find_target(toplevel_node, node) + else: + path = _yaml.node_find_target(toplevel_node, node, key=key) + roundtrip_file = roundtrip_cache.get(provenance.filename) if not roundtrip_file: roundtrip_file = roundtrip_cache[provenance.filename] = _yaml.roundtrip_load( |