techtonik / python-patch

Library to parse and apply unified diffs
https://pypi.python.org/pypi/patch
106 stars 63 forks source link

Support "test" mode to see if patch will apply cleanly #54

Closed typhillips closed 6 years ago

typhillips commented 6 years ago

As far as I can tell, there is no way to invoke the revert() or apply() methods in a "test" mode that would check to see if the patch can be applied successfully without actually modifying the target file. As it happens, I have an application for this. Obviously, I can do this externally by copying the target file in advance and reverting it after the patch is (or isn't) applied, but it would be convenient to have this built in.

If you think this would be useful but don't have the time or interest to work on it, I'd be happy to attempt it, as it looks to be trivial to implement.

typhillips commented 6 years ago

Never mind! I can just run it with the --revert option to back out the patch.

Note to self: put brain in gear first, type later.

[mega facepalm]