This function makes sure that a revision is only marked as persisting
    for a token once.  This is important since some diff algorithms allow
    tokens to be copied more than once in a revision.  The id(token) should
    unique to the in-memory representation of any object, so we use that as
    unique token instance identifier.

def persist_revision_once(tokens, revision):
    """
    This function makes sure that a revision is only marked as persisting
    for a token once.  This is important since some diff algorithms allow
    tokens to be copied more than once in a revision.  The id(token) should
    unique to the in-memory representation of any object, so we use that as
    unique token instance identifier.
    """
    token_map = {id(token):token for token in tokens}
    for token in token_map.values():
        token.persist(revision)