commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnue] r8493 - trunk/gnue-common/src/definitions


From: reinhard
Subject: [gnue] r8493 - trunk/gnue-common/src/definitions
Date: Tue, 13 Jun 2006 15:17:51 -0500 (CDT)

Author: reinhard
Date: 2006-06-13 15:17:51 -0500 (Tue, 13 Jun 2006)
New Revision: 8493

Modified:
   trunk/gnue-common/src/definitions/GParserHelpers.py
Log:
Only merge on the same object tree level.


Modified: trunk/gnue-common/src/definitions/GParserHelpers.py
===================================================================
--- trunk/gnue-common/src/definitions/GParserHelpers.py 2006-06-13 20:04:03 UTC 
(rev 8492)
+++ trunk/gnue-common/src/definitions/GParserHelpers.py 2006-06-13 20:17:51 UTC 
(rev 8493)
@@ -166,30 +166,32 @@
 
   def merge (self, other, maxIdLength = None):
     """
-    Incorporate all subtrees from the given object tree of this instances type.
+    Merge another object tree into this tree.
 
+    The node itself is left untouched. All child nodes that don't exist in the
+    other tree are left untouched, too. All child nodes that exist in the other
+    tree are replaced by that version. All nodes that exist only in the other
+    tree are copied to the end of this tree.
+
     @param other: L{ParserObj} tree to be merged into this object tree
     """
 
-    # First find objects of the same type in the other tree
-    candidates = other.findChildrenOfType (self._type, True, True)
+    if self.__class__ != other.__class__:
+      raise AssignmentTypeError, (self, source)
 
     # We keep a mapping of all our children
     mine = {}
     for mc in self._children:
       mine [mc._id_ (maxIdLength)] = mc
 
-    # Iterate over all elements in the other tree having the same type
-    for item in candidates:
-      # and observe all their children ...
-      for otherChild in item._children:
-        # ... wether we have to start a recursive merge ...
-        if otherChild._id_ (maxIdLength) in mine:
-          mine [otherChild._id_ (maxIdLength)].merge (otherChild)
-        # ... or we can copy the subtree
-        else:
-          new = otherChild.__class__ (self)
-          new.assign (otherChild, True)
+    for otherChild in other._children:
+      # ... wether we have to start a recursive merge ...
+      if otherChild._id_ (maxIdLength) in mine:
+        mine [otherChild._id_ (maxIdLength)].merge (otherChild)
+      # ... or we can copy the subtree
+      else:
+        new = otherChild.__class__ (self)
+        new.assign (otherChild, True)
 
 
   # ---------------------------------------------------------------------------





reply via email to

[Prev in Thread] Current Thread [Next in Thread]