implement apply_patch

Huh, that was easy.