[Checkins] SVN: zc.catalogqueue/trunk/src/zc/catalogqueue/ Fixed a conflict-resolution bug (probably a class of bugs) involving

Jim Fulton jim at zope.com
Thu Oct 29 13:05:22 EDT 2009


Log message for revision 105369:
  Fixed a conflict-resolution bug (probably a class of bugs) involving
  events existing but unchanged in old and new states and not existing
  in committed state due to conflict resolution.
  

Changed:
  U   zc.catalogqueue/trunk/src/zc/catalogqueue/CatalogEventQueue.py
  U   zc.catalogqueue/trunk/src/zc/catalogqueue/queue.txt

-=-
Modified: zc.catalogqueue/trunk/src/zc/catalogqueue/CatalogEventQueue.py
===================================================================
--- zc.catalogqueue/trunk/src/zc/catalogqueue/CatalogEventQueue.py	2009-10-29 17:05:19 UTC (rev 105368)
+++ zc.catalogqueue/trunk/src/zc/catalogqueue/CatalogEventQueue.py	2009-10-29 17:05:22 UTC (rev 105369)
@@ -215,7 +215,9 @@
                         new = (0, antiEvent(old[1]))
                     elif new[1] is ADDED:
                         if policy == SAFE_POLICY:
-                            logger.error('Queue conflict on %s: ADDED on existing item' % uid)
+                            logger.error(
+                                'Queue conflict on %s: ADDED on existing item'
+                                % uid)
                             raise ConflictError
                         else:
                             if current and current[1] == REMOVED:
@@ -253,7 +255,12 @@
                     continue
 
                 committed_data[uid] = new
+            else:
+                # Both old and new have this event so new didn't touch it.
+                # remove it from old so we don't treat it as undone below.
+                del oldstate_data[uid]
 
+
         # Now handle remaining events in old that weren't in new.
         # These *must* be undone events!
         for uid, old in oldstate_data.items():

Modified: zc.catalogqueue/trunk/src/zc/catalogqueue/queue.txt
===================================================================
--- zc.catalogqueue/trunk/src/zc/catalogqueue/queue.txt	2009-10-29 17:05:19 UTC (rev 105368)
+++ zc.catalogqueue/trunk/src/zc/catalogqueue/queue.txt	2009-10-29 17:05:22 UTC (rev 105369)
@@ -195,3 +195,25 @@
       Couldn't find object for 0
 
     >>> handler.uninstall()
+
+Edgecase
+========
+
+If a "old" state has two 'ADDED' events, and the committed state processes the
+queue, and the "new" state modifies one of the objects marked for addition, the
+code marks the other for removal.
+
+    >>> from zc.catalogqueue.CatalogEventQueue import (
+    ...     CatalogEventQueue, ADDED, REMOVED, CHANGED, CHANGED_ADDED)
+    >>> cq = CatalogEventQueue()
+
+    >>> def resolve(old, committed, new):
+    ...     return sorted(cq._p_resolveConflict(
+    ...        {'_conflict_policy': 0, '_data': old},
+    ...        {'_conflict_policy': 0, '_data': committed},
+    ...        {'_conflict_policy': 0, '_data': new}
+    ...        )['_data'].items())
+
+    >>> resolve({1: (1, ADDED), 2: (1, ADDED)}, {},
+    ...         {1: (1, ADDED), 2: (3, REMOVED), 3: (1, ADDED)})
+    [(2, (3, 0)), (3, (1, 1))]



More information about the checkins mailing list