summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <daniel.silverstone@codethink.co.uk>2019-05-22 11:50:48 +0100
committerDaniel Silverstone <daniel.silverstone@codethink.co.uk>2019-05-22 11:50:58 +0100
commit7f333e80502c2d4c26bc226009e08f12a25e8719 (patch)
treeaef75922faf77640c3db40dfcc8d594d1f98f22c
parentd43ba46b11f1356d6014b3aa8593e896a45aed58 (diff)
downloadbuildstream-danielsilverstone-ct/composition-logging.tar.gz
Dodgy identity logging for compositiondanielsilverstone-ct/composition-logging
Signed-off-by: Daniel Silverstone <daniel.silverstone@codethink.co.uk>
-rw-r--r--src/buildstream/_yaml.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/buildstream/_yaml.py b/src/buildstream/_yaml.py
index cdab4269e..234fc7be1 100644
--- a/src/buildstream/_yaml.py
+++ b/src/buildstream/_yaml.py
@@ -31,6 +31,8 @@ from itertools import count
from ruamel import yaml
from ._exceptions import LoadError, LoadErrorReason
+import ujson
+import hashlib
# Without this, pylint complains about all the `type(foo) is blah` checks
# because it feels isinstance() is more idiomatic. Sadly, it is much slower to
@@ -68,6 +70,10 @@ class Node(namedtuple('Node', ['value', 'file_index', 'line', 'column'])):
# code which has access to such nodes would do this.
return what in self[0]
+ def _identity(self):
+ ordered = node_sanitize(self)
+ ustring = ujson.dumps(ordered, sort_keys=True, escape_forward_slashes=False).encode('utf-8')
+ return hashlib.sha256(ustring).hexdigest()
# File name handling
_FILE_LIST = []
@@ -945,6 +951,9 @@ def composite(target, source):
assert type(source[0]) is dict
assert type(target[0]) is dict
+ with open("/tmp/composition.log", "a") as fh:
+ fh.write("{} <- {}\n".format(target._identity(), source._identity()))
+
try:
composite_dict(target, source)
except CompositeError as e: