Commit dfe0fa26 authored by Jérome Perrin's avatar Jérome Perrin

Changes from 0.8.1.6

These changes were from http://www.nexedi.org/static/packages/source/erp5diff-0.8.1.6.tar.gz
parent fc4c404b
0.8.1.6 (unreleased) 0.8.1.6 (2015/04/23)
-------------------- --------------------
* Bug fix * Disable _removeStrictEqualsSubNodeList that can make a wrong result
* Add support of deletion/addition for tailed text nodes
0.8.1.5 (2011/08/08) 0.8.1.5 (2011/08/08)
-------------------- --------------------
......
...@@ -13,7 +13,7 @@ def read(name): ...@@ -13,7 +13,7 @@ def read(name):
return open(name).read() return open(name).read()
long_description=( long_description=(
read('README.rst') read('README')
+ '\n' + + '\n' +
read('CHANGES.txt') read('CHANGES.txt')
) )
......
...@@ -202,6 +202,7 @@ class ERP5Diff: ...@@ -202,6 +202,7 @@ class ERP5Diff:
for child in element: for child in element:
clone_node = deepcopy(child) clone_node = deepcopy(child)
update_element.append(clone_node) update_element.append(clone_node)
else:
update_element.text = element.text update_element.text = element.text
root.append(update_element) root.append(update_element)
...@@ -214,16 +215,6 @@ class ERP5Diff: ...@@ -214,16 +215,6 @@ class ERP5Diff:
update_element.text = text update_element.text = text
root.append(update_element) root.append(update_element)
def _xupdateInsertAfterTextNode(self, element, path, nsmap=None):
"""insert new tail text node
"""
root = self._getResultRoot()
insert_element = etree.Element('{%s}insert-after' % self._ns, nsmap=nsmap)
insert_element.attrib['select'] = path
text_element = etree.SubElement(insert_element, '{%s}text' % self._ns, nsmap=nsmap)
text_element.text = element.tail
root.append(insert_element)
def _xupdateRemoveElement(self, path, nsmap=None): def _xupdateRemoveElement(self, path, nsmap=None):
""" """
Remove an element at 'path'. Remove an element at 'path'.
...@@ -498,6 +489,9 @@ class ERP5Diff: ...@@ -498,6 +489,9 @@ class ERP5Diff:
-old_element (to remove) -old_element (to remove)
-new_element (to insert) -new_element (to insert)
""" """
# XXX we do nothing here for now
return old_list, new_list, {}
# XXX because the implementation below can return a wrong result
old_candidate_list = old_list[:] old_candidate_list = old_list[:]
new_candidate_list = new_list[:] new_candidate_list = new_list[:]
misplaced_node_dict = {} misplaced_node_dict = {}
...@@ -616,28 +610,20 @@ class ERP5Diff: ...@@ -616,28 +610,20 @@ class ERP5Diff:
self._testAttributes(old_node, new_node, child_path) self._testAttributes(old_node, new_node, child_path)
if not old_ignore_text and len(old_element): if not old_ignore_text and len(old_element):
# Mixed Content # Mixed Content
if ((old_node.text and old_node.text.strip()) or (new_node.text\ if old_node.text and old_node.text.strip() and new_node.text\
and new_node.text.strip())) and old_node.text != new_node.text\ and new_node.text.strip() and old_node.text != new_node.text:
and (self._checkIgnoreText(new_node) == self._checkIgnoreText(old_node)): text_path = child_path + '/text()[%i]' % (new_node.getparent().index(new_node))
text_path = child_path + '/text()[1]'
self._xupdateUpdateTextNode(new_node, new_node.text, self._xupdateUpdateTextNode(new_node, new_node.text,
text_path, nsmap=new_element.nsmap) text_path, nsmap=new_element.nsmap)
if ((old_node.tail and old_node.tail.strip()) or (new_node.tail\ if old_node.tail and old_node.tail.strip() and new_node.tail\
and new_node.tail.strip())) and old_node.tail != new_node.tail: and new_node.tail.strip() and old_node.tail != new_node.tail:
if old_node.tail:
# case 1: edit existing text node, usage of position should works to reach
# expected text node
position = 1 position = 1
position += len([sibling for sibling in old_node.itersiblings(preceding=True) if sibling.tail]) if new_node.getparent().text:
if old_node.getparent().text:
position += 1 position += 1
position += len([sibling for sibling in old_node.itersiblings(preceding=True) if sibling.tail])
text_path = path + '/text()[%i]' % (position) text_path = path + '/text()[%i]' % (position)
self._xupdateUpdateTextNode(new_node, new_node.tail, self._xupdateUpdateTextNode(new_node, new_node.tail,
text_path, nsmap=new_element.nsmap) text_path, nsmap=new_element.nsmap)
else:
# case 2: Means adding a new text node, the position is ambiguous,
# so use insert-after instead
self._xupdateInsertAfterTextNode(new_node, child_path, nsmap=new_element.nsmap)
self._compareChildNodes(old_node, new_node, child_path) self._compareChildNodes(old_node, new_node, child_path)
new_start = new_current + 1 new_start = new_current + 1
if new_current in new_object_left_index_set: if new_current in new_object_left_index_set:
......
This diff is collapsed.
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