@classmethod
    def create(cls, index, theirs, repo=None):
        diff = messages.DiffMessage()
        diff.indexes = []
        diff.indexes.append(theirs or messages.IndexMessage())
        diff.indexes.append(index or messages.IndexMessage())

        index_paths_to_shas = {}
        their_paths_to_shas = {}

        for file_message in index.files:
            index_paths_to_shas[file_message.path] = file_message.sha
        for file_message in theirs.files:
            their_paths_to_shas[file_message.path] = file_message.sha

        for path, sha in index_paths_to_shas.iteritems():
            if path in their_paths_to_shas:
                if index_paths_to_shas[path] == their_paths_to_shas[path]:
                    file_message = messages.FileMessage()
                    file_message.path = path
                    file_message.deployed = theirs.deployed
                    file_message.deployed_by = theirs.deployed_by
                    diff.nochanges.append(file_message)
                else:
                    file_message = messages.FileMessage()
                    file_message.path = path
                    file_message.deployed = theirs.deployed
                    file_message.deployed_by = theirs.deployed_by
                    diff.edits.append(file_message)
                del their_paths_to_shas[path]
            else:
                file_message = messages.FileMessage()
                file_message.path = path
                diff.adds.append(file_message)

        for path, sha in their_paths_to_shas.iteritems():
            file_message = messages.FileMessage()
            file_message.path = path
            file_message.deployed = theirs.deployed
            file_message.deployed_by = theirs.deployed_by
            diff.deletes.append(file_message)

        # What changed in the pod between deploy commits.
        if (repo is not None
            and index.commit and index.commit.sha
            and theirs.commit and theirs.commit.sha):
            try:
                what_changed = repo.git.log(
                    '--date=short',
                    '--pretty=format:[%h] %ad <%ae> %s',
                    '{}..{}'.format(theirs.commit.sha, index.commit.sha))
                diff.what_changed = what_changed.decode('utf-8')
            except git.exc.GitCommandError:
                logging.info('Unable to determine changes between deploys.')

        # If on the original deploy show commit log messages only.
        elif (repo is not None
              and index.commit and index.commit.sha):
            what_changed = repo.git.log(
                  '--date=short',
                  '--pretty=format:[%h] %ad <%ae> %s')
            diff.what_changed = what_changed.decode('utf-8')

        return diff
dataset/ETHPy150Open grow/grow/grow/deployments/indexes.py/Diff.create/original