[CalendarServer-changes] [15067] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Fri Aug 21 12:47:02 PDT 2015


Revision: 15067
          http://trac.calendarserver.org//changeset/15067
Author:   cdaboo at apple.com
Date:     2015-08-21 12:47:02 -0700 (Fri, 21 Aug 2015)
Log Message:
-----------
Fix schedule-changes for overridden instance add/remove.

Modified Paths:
--------------
    CalendarServer/trunk/requirements-dev.txt
    CalendarServer/trunk/txdav/caldav/datastore/scheduling/icaldiff.py
    CalendarServer/trunk/txdav/caldav/datastore/scheduling/implicit.py
    CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py
    CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_icaldiff.py
    CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_itip.py

Modified: CalendarServer/trunk/requirements-dev.txt
===================================================================
--- CalendarServer/trunk/requirements-dev.txt	2015-08-21 19:43:49 UTC (rev 15066)
+++ CalendarServer/trunk/requirements-dev.txt	2015-08-21 19:47:02 UTC (rev 15067)
@@ -8,4 +8,4 @@
 q
 tl.eggdeps
 --editable svn+http://svn.calendarserver.org/repository/calendarserver/CalDAVClientLibrary/trunk@14856#egg=CalDAVClientLibrary
---editable svn+http://svn.calendarserver.org/repository/calendarserver/CalDAVTester/trunk@15029#egg=CalDAVTester
+--editable svn+http://svn.calendarserver.org/repository/calendarserver/CalDAVTester/trunk@15066#egg=CalDAVTester

Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/icaldiff.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/icaldiff.py	2015-08-21 19:43:49 UTC (rev 15066)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/icaldiff.py	2015-08-21 19:47:02 UTC (rev 15067)
@@ -756,7 +756,7 @@
         return partstatChanged
 
 
-    def whatIsDifferent(self, isiTip=True):
+    def whatIsDifferent(self, timeRangeCheck=False):
         """
         Compare the two calendar objects in their entirety and return a list of properties
         and PARTSTAT parameters that are different.
@@ -786,7 +786,7 @@
         for key in (oldset & newset):
             component1 = oldmap[key]
             component2 = newmap[key]
-            self._diffComponents(component1, component2, rids, needs_action_changes, isiTip)
+            self._diffComponents(component1, component2, rids, needs_action_changes, timeRangeCheck)
 
         # Now verify that each additional component in oldset matches a derived component in newset
         for key in oldset - newset:
@@ -794,27 +794,21 @@
             oldcomponent = oldmap[key]
             newcomponent = self.newcalendar.deriveInstance(rid)
             if newcomponent is None:
-                # For the non iTIP case we must report missing components on either side. Marking
-                # the DTSTART as changed is enough to trigger logic in the caller to treat this
-                # as a significant change.
-                if not isiTip:
-                    rids[rid.getText() if rid is not None else ""] = {"DTSTART": set()}
+                # Set the entry to None to indicate removal
+                rids[rid] = None
                 continue
-            self._diffComponents(oldcomponent, newcomponent, rids, needs_action_changes, isiTip)
+            self._diffComponents(oldcomponent, newcomponent, rids, needs_action_changes, timeRangeCheck)
 
         # Now verify that each additional component in oldset matches a derived component in newset
         for key in newset - oldset:
             rid = key[2]
             oldcomponent = self.oldcalendar.deriveInstance(rid)
             if oldcomponent is None:
-                # For the non iTIP case we must report missing components on either side. Marking
-                # the DTSTART as changed is enough to trigger logic in the caller to treat this
-                # as a significant change.
-                if not isiTip:
-                    rids[rid.getText() if rid is not None else ""] = {"DTSTART": set()}
+                # Set the entry to an empty dict to indicate addition
+                rids[rid] = {}
                 continue
             newcomponent = newmap[key]
-            self._diffComponents(oldcomponent, newcomponent, rids, needs_action_changes, isiTip)
+            self._diffComponents(oldcomponent, newcomponent, rids, needs_action_changes, timeRangeCheck)
 
         return (rids, needs_action_changes,)
 
@@ -843,8 +837,11 @@
         @rtype: L{bool}
         """
 
-        rids, _ignore_changes = self.whatIsDifferent(isiTip=False)
+        rids, _ignore_changes = self.whatIsDifferent(timeRangeCheck=True)
         for props in rids.values():
+            if not props:
+                # Component was added (props == {}) or removed (props is None)
+                return True
             props = frozenset(props.keys())
             if props & self.TRPROPS:
                 return True
@@ -868,6 +865,8 @@
         recurrence_reschedule = False
 
         for rid, props in diffs.iteritems():
+            if props is None:
+                continue
             if any([testprop in props for testprop in (
                 "DTSTART",
                 "DTEND",
@@ -921,13 +920,13 @@
         return (date_changed_rids, recurrence_reschedule,)
 
 
-    def _componentDuplicateAndNormalize(self, comp, isiTip=True):
+    def _componentDuplicateAndNormalize(self, comp, timeRangeCheck=False):
         comp = comp.duplicate()
         comp.normalizePropertyValueLists("EXDATE")
         comp.removeAlarms()
         comp.normalizeAll()
         comp.normalizeAttachments()
-        if isiTip:
+        if not timeRangeCheck:
             comp.removePropertyParameters("ORGANIZER", ("SCHEDULE-STATUS",))
             comp.removePropertyParameters("ATTENDEE", ("SCHEDULE-STATUS", "SCHEDULE-FORCE-SEND",))
             comp.removePropertyParameters("VOTER", ("SCHEDULE-STATUS", "SCHEDULE-FORCE-SEND",))
@@ -935,7 +934,7 @@
         return comp
 
 
-    def _diffComponents(self, comp1, comp2, rids, needs_action_rids, isiTip=True):
+    def _diffComponents(self, comp1, comp2, rids, needs_action_rids, timeRangeCheck=False):
 
         assert isinstance(comp1, Component) and isinstance(comp2, Component)
 
@@ -944,8 +943,8 @@
             return
 
         # Duplicate then normalize for comparison
-        comp1 = self._componentDuplicateAndNormalize(comp1, isiTip)
-        comp2 = self._componentDuplicateAndNormalize(comp2, isiTip)
+        comp1 = self._componentDuplicateAndNormalize(comp1, timeRangeCheck)
+        comp2 = self._componentDuplicateAndNormalize(comp2, timeRangeCheck)
 
         # Diff all the properties
         propdiff = set(comp1.properties()) ^ set(comp2.properties())

Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/implicit.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/implicit.py	2015-08-21 19:43:49 UTC (rev 15066)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/implicit.py	2015-08-21 19:47:02 UTC (rev 15067)
@@ -858,6 +858,10 @@
             checkOrganizerValue = False
             for rid, props in diffs.iteritems():
 
+                # Ignore this case - it should only happen when there is no master component
+                if not props:
+                    continue
+
                 # Ignore sequence only changes
                 if "SEQUENCE" in props and len(props) == 1:
                     continue

Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py	2015-08-21 19:43:49 UTC (rev 15066)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py	2015-08-21 19:47:02 UTC (rev 15067)
@@ -572,6 +572,11 @@
                 # Build the schedule-changes XML element
                 update_details = []
                 for rid, props_changed in sorted(rids.iteritems(), key=lambda x: x[0]):
+
+                    # We do not report removals as those will already have been processed via a CANCEL
+                    if props_changed is None:
+                        continue
+
                     recurrence = []
                     if rid is None:
                         recurrence.append(customxml.Master())

Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_icaldiff.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_icaldiff.py	2015-08-21 19:43:49 UTC (rev 15066)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_icaldiff.py	2015-08-21 19:47:02 UTC (rev 15067)
@@ -4719,8 +4719,8 @@
 END:VEVENT
 END:VCALENDAR
 """,
+                {"20080602T120000Z": None},
                 {},
-                {},
             ),
             (
                 "#4.2 Override component added",
@@ -4794,7 +4794,7 @@
 END:VEVENT
 END:VCALENDAR
 """,
-                {"20080602T120000Z": {"DTSTART": set()}},
+                {"20080602T120000Z": None},
                 {},
             ),
             (
@@ -4830,7 +4830,7 @@
 END:VEVENT
 END:VCALENDAR
 """,
-                {"20080602T120000Z": {"DTSTART": set()}},
+                {"20080602T120000Z": {}},
                 {},
             ),
         )
@@ -4845,7 +4845,8 @@
 
         for description, calendar1, calendar2, rids, changes in itertools.chain(data5,):
             differ = iCalDiff(Component.fromString(calendar1), Component.fromString(calendar2), False)
-            got_rids, got_changes = differ.whatIsDifferent(isiTip=False)
+            got_rids, got_changes = differ.whatIsDifferent()
+            rids = dict([(DateTime.parseText(k) if k else None, v) for k, v in rids.items()])
             self.assertEqual(got_rids, rids, msg="%s expected R-IDs: '%s', got: '%s'" % (description, rids, got_rids,))
             self.assertEqual(got_changes, changes, msg="%s expected changes R-IDs: '%s', got: '%s'" % (description, changes, got_changes,))
 

Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_itip.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_itip.py	2015-08-21 19:43:49 UTC (rev 15066)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_itip.py	2015-08-21 19:47:02 UTC (rev 15067)
@@ -115,7 +115,7 @@
 END:VEVENT
 END:VCALENDAR
 """,
-                0,
+                1,
             ),
             (
                 "2.1 partstat change pinned to sequence - changed",
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150821/0a6a2703/attachment-0001.html>


More information about the calendarserver-changes mailing list