Commit df17ebbc authored by Ayush Tiwari's avatar Ayush Tiwari

ERP5Type/patches: Sort before trying to diff tuples in DiffTool

This is essential to have better aesthetic of Deepdiff diff for tuples.
In general, we treat iterables as long string so as to bypass the complicated
diff for iterables provided by DeepDiff, but for tuples this was creating a
problem as it was not possible to understand the diff properly.

Hence, by soting them, we get more understandable diff for tuples.

Also, there is no need to override `__diff_tuple` function as it is itself
dependent on `__diff_iterable` which we already override.
parent a71d577e
......@@ -70,7 +70,15 @@ def DeepDiff__diff(self, level, parents_ids=frozenset({})):
self._DeepDiff__diff_dict(level, parents_ids)
elif isinstance(level.t1, tuple):
self._DeepDiff__diff_str(level)
# Sort the values for t1 and t2 before diffing tuples.
# Reason being that we except tuples and other iterables to be diffed
# as a string so as not to use the forced feature of recursive diff
# by deepdiff. Thus, sorting tuples before diffing will atleast give us
# diff in the format where we would be able to see the more asthetic
# diff for tuples.
level.t1 = sorted(level.t1)
level.t2 = sorted(level.t2)
self._DeepDiff__diff_tuple(level, parents_ids)
elif isinstance(level.t1, (set, frozenset)):
self._DeepDiff__diff_set(level)
......
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