"""Allow appended human saves during acceptance, never rewritten old revisions."""
from .pose_review_geometry import canonical


def saved_revision_preserved(previous,current):
    if not isinstance(current,dict) or current.get('target_key')!=previous['target_key']:
        return False
    if current.get('source_binding')!=previous.get('source_binding'):
        return False
    revision=current.get('revision')
    if type(revision) is not int or revision<previous['revision']:
        return False
    return revision>previous['revision'] or canonical(previous)==canonical(current)


def event_prefix_preserved(previous,current):
    return len(current)>=len(previous) and current[:len(previous)]==previous
