def undo_patch(revised, patch):
    """
    Undo the changes specified in the given patch

    :param revised: the changed text
    :param patch: the patch to undo the changes in
    :exception PatchFailedException: if unable to undo the changes
    :return: the original text
    """
    if isinstance(revised, str):
        revised = revised.splitlines()
    patch.restore(revised)
