Fish Trophy

chipx86 got a fish trophy!

Fish Trophy

Add a Patcher class for handling the application of patches.

Review Request #14041 — Created July 14, 2024 and updated — Latest diff uploaded

Information

RBTools
release-5.x

Reviewers

The new Patcher class is responsible for taking a list of patches and
applying or reverting them, optionally committing them as well.

Consumers of Patcher are expected to provide the list of patches to
apply (each being a Patch object), the destination path (optionally),
any information known about the repository, and flags to initiate a
revert or squash of the patches.

If the patches are to be committed, they're then expected to call
prepare_for_commit(). Then, patch() can be called.

Patcher.patch() is a generator, taking care to apply each patch in
order and yielding a successful result for each or raising an exception.
Consumers can use the generator nature of this tool to help with
progress reporting.

By default, this interfaces with the local patch tool, supporting both
GNU Patch and Apple/BSD Patch. It takes care to examine output for both
tools and convert them into suitable responses. Subclasses can override
the methods to instead interface with SCM-specific patching tools, and
to even take care to apply or commit multiple patches in one go instead
of individually (which is needed for Mercurial).

Follow-up changes will begin integrating Patcher into the SCMs and
into rbt patch and rbt land.

Unit tests pass.

Commits

Files