# HG changeset patch # User Paul Boddie # Date 1515860704 -3600 # Node ID 1550293500d7b6608c2dd8aea12728db2e4e6837 # Parent ffcb65f7b8e5a579716bb7f7c2e1a8582c73c1e4 Adjusted the logic around counter-proposals, replacing the "retained modified" group of periods with a "newly-replaced" group, because all retained periods should be unmodified, whereas previously-retained periods become classified as replaced when modified. diff -r ffcb65f7b8e5 -r 1550293500d7 imiptools/editing.py --- a/imiptools/editing.py Fri Jan 12 21:56:34 2018 +0100 +++ b/imiptools/editing.py Sat Jan 13 17:25:04 2018 +0100 @@ -1434,17 +1434,18 @@ active_periods = new + replaced + retained active_non_rule = filter(lambda p: p.origin != "RRULE", active_periods) - # Modified replaced and retained recurrences are used for incremental - # updates. + # Modified replaced recurrences are used for incremental updates. replaced_modified = select_recurrences(replaced, modified).values() - retained_modified = select_recurrences(retained, modified).values() - # Unmodified replaced and retained recurrences are used in the complete - # event summary. + # Unmodified replaced recurrences are used in the complete event summary. replaced_unmodified = subtract_recurrences(replaced, modified).values() - retained_unmodified = subtract_recurrences(retained, modified).values() + + # Determine any new replacement periods. These are edited periods that were + # not previously replacements. + + replaced_new = filter(lambda p: p.new_replacement, replaced) # Obtain the removed periods in terms of existing periods. These are used in # incremental updates. @@ -1466,18 +1467,12 @@ # Cancelled periods originating from rules must be excluded since there are # no explicit instances to be deleted. - cancelled_rule = [] - for p in cancelled_removed: - if p.origin == "RRULE": - cancelled_rule.append(p) + cancelled_rule = filter(lambda p: p.origin == "RRULE", cancelled_removed) # Obsolete periods (replaced by other periods) originating from rules must # be excluded if no explicit instance will be used to replace them. - obsolete_rule = [] - for p in obsolete: - if p.origin == "RRULE": - obsolete_rule.append(p) + obsolete_rule = filter(lambda p: p.origin == "RRULE", obsolete) # As organiser... @@ -1509,7 +1504,7 @@ to_set = [] to_exclude = [] to_unschedule = cancelled_removed - to_reschedule = list(chain(replaced_modified, retained_modified, reinstated)) + to_reschedule = list(chain(replaced_modified, reinstated)) to_add = new all_unscheduled = cancelled_unmodified all_rescheduled = list(chain(replaced_unmodified, to_reschedule)) @@ -1520,27 +1515,27 @@ to_unschedule = [] to_add = [] - # Changed periods without new or removed periods are proposed as - # separate changes. Parent event changes cause redefinition of the - # entire event. + # Parent event changes cause redefinition of the entire event. + # The event is defined in terms of new periods and exceptions for + # removed periods or obsolete rule periods. - if not new and not removed and not is_changed: - to_set = [] - to_exclude = [] - to_reschedule = list(chain(replaced_modified, retained_modified, reinstated)) - all_unscheduled = list(cancelled_unmodified) - all_rescheduled = list(chain(replaced_unmodified, to_reschedule)) - - # Otherwise, the event is defined in terms of new periods and - # exceptions for removed periods or obsolete rule periods. - - else: + if new or removed or is_changed or reinstated or replaced_new: to_set = active_non_rule to_exclude = list(chain(cancelled, obsolete_rule, cancelled_main)) to_reschedule = [] all_unscheduled = [] all_rescheduled = [] + # Changed periods without new or removed periods are proposed as + # separate changes. + + else: + to_set = [] + to_exclude = [] + to_reschedule = replaced_modified + all_unscheduled = cancelled_unmodified + all_rescheduled = list(chain(replaced_unmodified, to_reschedule)) + return to_unschedule, to_reschedule, to_add, to_exclude, to_set, all_unscheduled, all_rescheduled def get_period_mapping(periods):