WIP: ERP5 Diff Language
ERP5 Diff Language is a step to be able to diff any two ERP5-Fied
objects as well as their properties.
We will be using ERP5 DiffTool which will be the creating DIff for the objects.
The places where we need to have diffs are:
- Portal components
text_content
: DONE - ZODB History tab to show diff between two versions of an object : DONE
- Web pages
text_content
: DONE - Change in properties between any 2 ERP5 versions or objects
- Diff while installing Business Templates
Diffs can be displayed in 2 formats: XML or JSON. The default would be JSON as it provides more clear image of what are the properties of ERP5 object. Thanks to deepdiff
, we can have this in a nice beautiful format. But just having JSON diff will not be beneficial for objects having large text_content
as it'll only be showing old and new value which we already have in ZODB History Tab.
A perfect diff should be mixture of separate diffs for different fields and properties depending on their types. Also, it should be in a field which can be displayed inside the new ERP5 interface.
So, the combined changes which we should expect from this MR:
- JSON format of ERP5 objects .
status: Currently using the XML representation of ERP5 object provided by
XMLExportImport
and then converting it to JSON and vice-versa. -
ERP5 Diff Tool
to be used everywhere where we want diff rather than directly relying onerp5diff
or any other library. More clearly,erp5diff
or other works done for diff inside ERP5 should all be part of Diff Tool to maintain consistency.
Products.CMFDiffTool already has some similar diffs for different property types which can be improved and reused. We will need deeepdiff
to find diff between JSON-fied ERP5 objects. This will give us more control to modify the diff and present it as we want.
Steps for getting diff for any object:
-
Diff between 2 versions: Use a python script
Base_getZODBHistoryDiff
: This should return a list of Diffs between different versions of object. We will be usingserial number
of versions to find out the diff between 2 versions. Make sure that the list should return value in same way that they are being done right now, so that we don't bother to change theZODB History
tab and how they are displayed. The displays should only change for the diffs. -
Diff between 2 objects: This should use a script
Base_getObjectDiff
. In case the objects are different, it should work in same way as for same object.
How we calculate a diff with 2 objects given:
- Convert the objects to their JSON format.
- Use
deepdiff
to find out the diff for the 2 JSON objects. - Return a JSON object as a diff. This JSON object will be used in their respective scripts to show the diff.
TODO
- Important: Find better way to give JSON representation of ERP5 objects. Its not a good idea to convert the generated XML to JSON.
-
Separate the diff for JSON object checking every property. Use
Products.CMFDiffTool
- Take care for different use cases: different objects, no-exisiting property, property which are non-picklable
- Merge the properties diff to give a JSON Diff for an object.
-
Add view for
Base_getObjectDiff
script. Use thediff
fortext_content
and display in renderJS gadget. - Add tests for unified diff(s)