Commit 1692fd42 authored by Nicolas Delaby's avatar Nicolas Delaby

Some nodes stay orphans if they are replaced by another one and followed

by a modification. This patch address this issue.
parent 8748c709
......@@ -581,6 +581,8 @@ class ERP5Diff:
path_list = self._makeRelativePathList(old_list)
new_start = 0
new_len = len(new_list)
# Usefull set to detect orphan in new_list
new_object_left_index_set = set()
for old_node, node_path in zip(old_list, path_list):
child_path = self._concatPath(path, node_path)
for new_current in range(new_start, new_len):
......@@ -589,13 +591,24 @@ class ERP5Diff:
self._testAttributes(old_node, new_node, child_path)
self._compareChildNodes(old_node, new_node, child_path)
new_start = new_current + 1
if new_current in new_object_left_index_set:
new_object_left_index_set.remove(new_current)
break
else:
new_object_left_index_set.add(new_current)
else:
# There is no matching node. So this element must be removed.
self._xupdateRemoveElement(child_path, old_node.nsmap)
if new_len > new_start:
# There are remaining nodes in the new children.
self._xupdateAppendElements(new_list[new_start:new_len], path)
# if New children are allready added, clean up new_object_left_index_set
[new_object_left_index_set.remove(index)\
for index in range(new_start, new_len) if\
index in new_object_left_index_set]
if new_object_left_index_set:
self._xupdateAppendElements([new_list[index] for index \
in new_object_left_index_set], path)
if misplaced_node_dict:
self._xupdateMoveElements(misplaced_node_dict, path)
......
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