Move RelationCounterField InstanceState field ops into RelationTracker.
Review Request #9758 — Created March 7, 2018 and submitted — Latest diff uploaded
InstanceState
had a number of methods for setting counter field data
in the database, which was then being called byRelationTracker
. By
having these split up, each call inRelationTracker
had to be
accompanied by additional calls for synchronizing the values to other
model instances in other states, complicating those calls. It also meant
thatInstanceState
had to own a handful of functions that didn't
really need to be there.This change moves those out into
RelationTracker
, and in the process
simplifies each of their implementations by using a contextmanager that
takes care of splitting up the states into "main" and "other" states
(removing the need for_separate_saved_states()
) and then handling the
synchronizing (simplifying all call sites).This is the second in a series of changes for simplifying the
implementation ofRelationCounterField
and making it less prone to
deadlocking issues.
All unit tests pass.