Move RelationCounterField InstanceState field ops into RelationTracker.
Review Request #9758 — Created March 7, 2018 and submitted
InstanceStatehad a number of methods for setting counter field data
in the database, which was then being called by
having these split up, each call in
RelationTrackerhad to be
accompanied by additional calls for synchronizing the values to other
model instances in other states, complicating those calls. It also meant
InstanceStatehad 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
RelationCounterFieldand making it less prone to
All unit tests pass.