synapse/state.py
def _seperate(state_sets):
    """Takes the state_sets and figures out which keys are conflicted and
    which aren't. i.e., which have multiple different event_ids associated
    with them in different state sets.

    Args:
        state_sets(list[dict[(str, str), str]]):
            List of dicts of (type, state_key) -> event_id, which are the
            different state groups to resolve.

    Returns:
        (dict[(str, str), str], dict[(str, str), set[str]]):
            A tuple of (unconflicted_state, conflicted_state), where:

            unconflicted_state is a dict mapping (type, state_key)->event_id
            for unconflicted state keys.

            conflicted_state is a dict mapping (type, state_key) to a set of
            event ids for conflicted state keys.
    """
    unconflicted_state = dict(state_sets[0])
    conflicted_state = {}

    for state_set in state_sets[1:]:
        for key, value in state_set.iteritems():
            # Check if there is an unconflicted entry for the state key.
            unconflicted_value = unconflicted_state.get(key)
            if unconflicted_value is None:
                # There isn't an unconflicted entry so check if there is a
                # conflicted entry.
                ls = conflicted_state.get(key)
                if ls is None:
                    # There wasn't a conflicted entry so haven't seen this key before.
                    # Therefore it isn't conflicted yet.
                    unconflicted_state[key] = value
                else:
                    # This key is already conflicted, add our value to the conflict set.
                    ls.add(value)
            elif unconflicted_value != value:
                # If the unconflicted value is not the same as our value then we
                # have a new conflict. So move the key from the unconflicted_state
                # to the conflicted state.
                conflicted_state[key] = {value, unconflicted_value}
                unconflicted_state.pop(key, None)

    return unconflicted_state, conflicted_state
Takes the state_sets and figures out which keys are conflicted and
    which aren't. i.e., which have multiple different event_ids associated
    with them in different state sets.

    Args:
        state_sets(list[dict[(str, str), str]]):
            List of dicts of (type, state_key) -> event_id, which are the
            different state groups to resolve.

    Returns:
        (dict[(str, str), str], dict[(str, str), set[str]]):
            A tuple of (unconflicted_state, conflicted_state), where:

            unconflicted_state is a dict mapping (type, state_key)->event_id
            for unconflicted state keys.

            conflicted_state is a dict mapping (type, state_key) to a set of
            event ids for conflicted state keys.
    
Takes the state_sets and figures out which keys are conflicted and
which aren't. i.e., which have multiple different event_ids associated
with them in different state sets.
Takes the state_sets and figures out which keys are conflicted and which aren ' t . i . e . which have multiple different event_ids associated with them in different state sets .
def _seperate(state_sets):
    unconflicted_state = dict(state_sets[0])
    conflicted_state = {}
    for state_set in state_sets[1:]:
        for key, value in state_set.iteritems():
            unconflicted_value = unconflicted_state.get(key)
            if unconflicted_value is None:
                ls = conflicted_state.get(key)
                if ls is None:
                    unconflicted_state[key] = value
                else:
                    ls.add(value)
            elif unconflicted_value != value:
                conflicted_state[key] = {value, unconflicted_value}
                unconflicted_state.pop(key, None)
    return unconflicted_state, conflicted_state
def _seperate ( state_sets ) : unconflicted_state = dict ( state_sets [ 0 ] ) conflicted_state = { } for state_set in state_sets [ 1 : ] : for key , value in state_set . iteritems ( ) : unconflicted_value = unconflicted_state . get ( key ) if unconflicted_value is None : ls = conflicted_state . get ( key ) if ls is None : unconflicted_state [ key ] = value else : ls . add ( value ) elif unconflicted_value != value : conflicted_state [ key ] = { value , unconflicted_value } unconflicted_state . pop ( key , None ) return unconflicted_state , conflicted_state
Takes the state_sets and figures out which keys are conflicted and
which aren't.
Takes the state_sets and figures out which keys are conflicted and which aren ' t .
"""Takes the state_sets and figures out which keys are conflicted and
    which aren't. i.e., which have multiple different event_ids associated
    with them in different state sets.

    Args:
        state_sets(list[dict[(str, str), str]]):
            List of dicts of (type, state_key) -> event_id, which are the
            different state groups to resolve.

    Returns:
        (dict[(str, str), str], dict[(str, str), set[str]]):
            A tuple of (unconflicted_state, conflicted_state), where:

            unconflicted_state is a dict mapping (type, state_key)->event_id
            for unconflicted state keys.

            conflicted_state is a dict mapping (type, state_key) to a set of
            event ids for conflicted state keys.
    """ # Check if there is an unconflicted entry for the state key. # There isn't an unconflicted entry so check if there is a # conflicted entry. # There wasn't a conflicted entry so haven't seen this key before. # Therefore it isn't conflicted yet. # This key is already conflicted, add our value to the conflict set. # If the unconflicted value is not the same as our value then we # have a new conflict. So move the key from the unconflicted_state # to the conflicted state.


unconflicted_state is a dict mapping (type, state_key)->event_id
for unconflicted state keys.

conflicted_state is a dict mapping (type, state_key) to a set of
event ids for conflicted state keys.
unconflicted_state is a dict mapping ( type state_key ) - > event_id for unconflicted state keys . conflicted_state is a dict mapping ( type state_key ) to a set of event ids for conflicted state keys .
state_sets
List of dicts of (type, state_key) -> event_id, which are the
different state groups to resolve.
List of dicts of ( type state_key ) - > event_id which are the different state groups to resolve .