[Erp5-report] r35525 nicolas - in /erp5/trunk/utils/erp5diff: ERP5Diff.py README
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri May 21 14:35:10 CEST 2010
Author: nicolas
Date: Fri May 21 14:35:08 2010
New Revision: 35525
URL: http://svn.erp5.org?rev=35525&view=rev
Log:
* In node comparaison discard text nodes with only withe-spaces.
* Add tests
Modified:
erp5/trunk/utils/erp5diff/ERP5Diff.py
erp5/trunk/utils/erp5diff/README
Modified: erp5/trunk/utils/erp5diff/ERP5Diff.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5diff/ERP5Diff.py?rev=35525&r1=35524&r2=35525&view=diff
==============================================================================
--- erp5/trunk/utils/erp5diff/ERP5Diff.py [utf8] (original)
+++ erp5/trunk/utils/erp5diff/ERP5Diff.py [utf8] Fri May 21 14:35:08 2010
@@ -394,11 +394,19 @@
"""
Determine if text should be ignored by heuristics,
because ERP5 does not define any schema at the moment.
+ We ignore white-space text nodes between elements.
+ pseudo code:
+ tree = parse("
+ <node>
+ </node>")
+ tree.node.text == '\n '
"""
for child in element:
if type(child) == etree._Element:
return True
- return False
+ if element.text is None:
+ return True
+ return bool(element.text.strip()) is False or False
def _makeRelativePathList(self, element_list, before=0):
"""
@@ -555,10 +563,6 @@
# Nothing to do.
self._p("Both are empty.")
pass
- elif old_is_empty or new_is_empty:
- # Perhaps they are very different.
- self._p("One of them is empty, so just update all the contents.")
- self._xupdateUpdateElement(new_element, path, nsmap=new_element.nsmap)
else:
# Second, determine if text should be ignored.
old_ignore_text = self._checkIgnoreText(old_element)
Modified: erp5/trunk/utils/erp5diff/README
URL: http://svn.erp5.org/erp5/trunk/utils/erp5diff/README?rev=35525&r1=35524&r2=35525&view=diff
==============================================================================
--- erp5/trunk/utils/erp5diff/README [utf8] (original)
+++ erp5/trunk/utils/erp5diff/README [utf8] Fri May 21 14:35:08 2010
@@ -941,5 +941,64 @@
</xupdate:insert-after>
</xupdate:modifications>
+29. Delete children with white-space as text nodes
+ >>> old_xml = """
+ ... <object>
+ ... <local_permission type="tokens" id="View">
+ ... <marshal:marshal xmlns:marshal="http://www.erp5.org/namespaces/marshaller">
+ ... <marshal:tuple>
+ ... <marshal:string>Assignee</marshal:string>
+ ... <marshal:string>Assignor</marshal:string>
+ ... </marshal:tuple>
+ ... </marshal:marshal>
+ ... </local_permission>
+ ... </object>
+ ... """
+ >>> new_xml = """
+ ... <object>
+ ... <local_permission type="tokens" id="View">
+ ... <marshal:marshal xmlns:marshal="http://www.erp5.org/namespaces/marshaller">
+ ... <marshal:tuple>
+ ... </marshal:tuple>
+ ... </marshal:marshal>
+ ... </local_permission>
+ ... </object>
+ ... """
+ >>> erp5diff.compare(old_xml, new_xml)
+ >>> erp5diff.output()
+ <xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
+ <xupdate:remove xmlns:marshal="http://www.erp5.org/namespaces/marshaller" select="/object/local_permission[@id='View']/marshal:marshal/marshal:tuple/marshal:string[1]"/>
+ <xupdate:remove xmlns:marshal="http://www.erp5.org/namespaces/marshaller" select="/object/local_permission[@id='View']/marshal:marshal/marshal:tuple/marshal:string[2]"/>
+ </xupdate:modifications>
+
+29Bis. Delete childrens with auto-closing nodes
+ >>> old_xml = """
+ ... <object>
+ ... <local_permission type="tokens" id="View">
+ ... <marshal:marshal xmlns:marshal="http://www.erp5.org/namespaces/marshaller">
+ ... <marshal:tuple>
+ ... <marshal:string>Assignee</marshal:string>
+ ... <marshal:string>Assignor</marshal:string>
+ ... </marshal:tuple>
+ ... </marshal:marshal>
+ ... </local_permission>
+ ... </object>
+ ... """
+ >>> new_xml = """
+ ... <object>
+ ... <local_permission type="tokens" id="View">
+ ... <marshal:marshal xmlns:marshal="http://www.erp5.org/namespaces/marshaller">
+ ... <marshal:tuple/>
+ ... </marshal:marshal>
+ ... </local_permission>
+ ... </object>
+ ... """
+ >>> erp5diff.compare(old_xml, new_xml)
+ >>> erp5diff.output()
+ <xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
+ <xupdate:remove xmlns:marshal="http://www.erp5.org/namespaces/marshaller" select="/object/local_permission[@id='View']/marshal:marshal/marshal:tuple/marshal:string[1]"/>
+ <xupdate:remove xmlns:marshal="http://www.erp5.org/namespaces/marshaller" select="/object/local_permission[@id='View']/marshal:marshal/marshal:tuple/marshal:string[2]"/>
+ </xupdate:modifications>
+
- 2003-12-04, Yoshinori OKUJI <yo at nexedi.com>
- 2009-09-15, Tatuya Kamada <tatuya at nexedi.com>
More information about the Erp5-report
mailing list