[Erp5-report] r36983 nicolas - /erp5/trunk/utils/erp5diff/ERP5Diff.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Jul 8 15:55:08 CEST 2010
Author: nicolas
Date: Thu Jul 8 15:55:07 2010
New Revision: 36983
URL: http://svn.erp5.org?rev=36983&view=rev
Log:
Some nodes stay orphans if they are replaced by another one and followed
by a modification. This patch address this issue.
Modified:
erp5/trunk/utils/erp5diff/ERP5Diff.py
Modified: erp5/trunk/utils/erp5diff/ERP5Diff.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5diff/ERP5Diff.py?rev=36983&r1=36982&r2=36983&view=diff
==============================================================================
--- erp5/trunk/utils/erp5diff/ERP5Diff.py [utf8] (original)
+++ erp5/trunk/utils/erp5diff/ERP5Diff.py [utf8] Thu Jul 8 15:55:07 2010
@@ -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)
More information about the Erp5-report
mailing list