'Build an EventContext structure for the event.
Args:
event (synapse.events.EventBase):
Returns:
synapse.events.snapshot.EventContext:'

@defer.inlineCallbacks
def compute_event_context(self, event, old_state=None):

    if event.internal_metadata.is_outlier():
        context = EventContext()
        if old_state:
            context.prev_state_ids = {(s.type, s.state_key): s.event_id for s in old_state}
            if event.is_state():
                context.current_state_ids = dict(context.prev_state_ids)
                key = (event.type, event.state_key)
                context.current_state_ids[key] = event.event_id
            else:
                context.current_state_ids = context.prev_state_ids
        else:
            context.current_state_ids = {}
            context.prev_state_ids = {}
        context.prev_state_events = []
        context.state_group = self.store.get_next_state_group()
        defer.returnValue(context)
    if old_state:
        context = EventContext()
        context.prev_state_ids = {(s.type, s.state_key): s.event_id for s in old_state}
        context.state_group = self.store.get_next_state_group()
        if event.is_state():
            key = (event.type, event.state_key)
            if (key in context.prev_state_ids):
                replaces = context.prev_state_ids[key]
                if (replaces != event.event_id):
                    event.unsigned['replaces_state'] = replaces
            context.current_state_ids = dict(context.prev_state_ids)
            context.current_state_ids[key] = event.event_id
        else:
            context.current_state_ids = context.prev_state_ids
        context.prev_state_events = []
        defer.returnValue(context)
    logger.debug('calling    resolve_state_groups    from    compute_event_context')
    entry = (yield self.resolve_state_groups(event.room_id, [e for (e, _) in event.prev_events]))
    curr_state = entry.state
    context = EventContext()
    context.prev_state_ids = curr_state
    if event.is_state():
        context.state_group = self.store.get_next_state_group()
        key = (event.type, event.state_key)
        if (key in context.prev_state_ids):
            replaces = context.prev_state_ids[key]
            event.unsigned['replaces_state'] = replaces
        context.current_state_ids = dict(context.prev_state_ids)
        context.current_state_ids[key] = event.event_id
        if entry.state_group:
            context.prev_group = entry.state_group
            context.delta_ids = {key: event.event_id}
        elif entry.prev_group:
            context.prev_group = entry.prev_group
            context.delta_ids = dict(entry.delta_ids)
            context.delta_ids[key] = event.event_id
    else:
        if (entry.state_group is None):
            entry.state_group = self.store.get_next_state_group()
            entry.state_id = entry.state_group
        context.state_group = entry.state_group
        context.current_state_ids = context.prev_state_ids
        context.prev_group = entry.prev_group
        context.delta_ids = entry.delta_ids
    context.prev_state_events = []
    defer.returnValue(context)
