Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
erp5diff
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
erp5diff
Commits
6d753a49
Commit
6d753a49
authored
May 21, 2010
by
Nicolas Delaby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* In node comparaison discard text nodes with only withe-spaces.
* Add tests
parent
c9ecea0b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
5 deletions
+68
-5
ERP5Diff.py
ERP5Diff.py
+9
-5
README
README
+59
-0
No files found.
ERP5Diff.py
View file @
6d753a49
...
...
@@ -394,11 +394,19 @@ class ERP5Diff:
"""
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 @@ class ERP5Diff:
# 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
)
...
...
README
View file @
6d753a49
...
...
@@ -941,5 +941,64 @@ does not work as bellow example. This is a known bug.
</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@nexedi.com>
- 2009-09-15, Tatuya Kamada <tatuya@nexedi.com>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment