Add a new Patch class for representing patches to apply.
Review Request #13969 — Created June 10, 2024 and submitted
The new
rbtools.diffs.patches.Patchrepresents a patch that can be
applied to a source tree. It consists of patch content or a patch file
path, along with optional information needed to apply the patch, such as
the commit author and message, base directory, and path prefix strip
level.To access the contents of a
Patch, you first callopen(). This is a
context manager that ensures you can get to the content or file path,
and that any temporary state is then cleaned up after use.A
Patchcan also be assigned to aPatchResult. This is optional,
but will let a receiver of aPatchResultaccess information on the
underlyingPatch.Currently,
Patchisn't being used, but it will form a key part of the
upcoming work on how patches get applied to repositories.
Unit tests pass.
Tested this in some in-progress patching code.
- Change Summary:
-
Patch.prefix_levelis now optional, which will be needed to ensure SCMs can determine defaults. - Commits:
-
Summary ID f8a878772e62eaaf3f5ebc5edfc6658c420a3aeb b15a961fe0217762f9b8a4c2b7f23bba81034e10