Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
erp5 erp5
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Labels
    • Labels
  • Merge requests 139
    • Merge requests 139
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Environments
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Jobs
  • Commits
Collapse sidebar
  • nexedi
  • erp5erp5
  • Merge requests
  • !451

Closed
Created Oct 12, 2017 by Ayush Tiwari@tiwariayushContributor4 of 6 tasks completed4/6 tasks
  • Report abuse
Report abuse

WIP: ERP5 Diff Language

  • Overview 11
  • Commits 30
  • Changes 97

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:

  1. 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.
  2. ERP5 Diff Tool to be used everywhere where we want diff rather than directly relying on erp5diff 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:

  1. 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 using serial 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 the ZODB History tab and how they are displayed. The displays should only change for the diffs.

  2. 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:

  1. Convert the objects to their JSON format.
  2. Use deepdiff to find out the diff for the 2 JSON objects.
  3. 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.
    • https://github.com/collective/collective.jsonify
    • https://docs.plone.org/develop/plone/content/importexport.html#simple-json-export
    • https://github.com/datakurre/shaura_json/tree/master/shaura_json
    • https://github.com/4teamwork/ftw.jsondump
  • 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 the diff for text_content and display in renderJS gadget.
  • Add tests for unified diff(s)
Assignee
Assign to
Reviewer
Request review from
None
Milestone
None
Assign milestone
Time tracking
Source branch: erp5_diff
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7