Switch RBTools to use modern patching, and add a legacy patch wrapper.
Review Request #14224 — Created Nov. 3, 2024 and submitted — Latest diff uploaded
rbt patchandrbt landnow use the newPatcherclass
(specifically, aSCMClientPatcher), which gives SCMClients a lot more
control over the patching and committing process.By default, SCMClients that don't define custom patching logic will use
the built-in patching logic that leverages thepatchtool.SCMClients that override
apply_patch()will continue to use their
existing patching logic, but wrapped by a_LegacyPatcher
implementation that'll maintain compatibility until RBTools 7. This acts
as a bridge between the newPatcherAPI and legacy implementations of
SCMClient.apply_patch()andSCMClient.apply_patch_for_empty_files()
rbt patchandrbt landwill callSCMClient.get_patcher()to return
aSCMClientPatcher-compatible instance for handling patching
operations.Now, there's a little bit of a complex transition here.
SCMClient.apply_patch()will remain a valid function for applying
patches for the time-being, but its behavior changes between the legacy
patcher and the modern patcher:
-
By default, a SCMClient that doesn't implement custom patching
behavior) will use a defaultapply_patch()method that gets a
defaultSCMClientPatcherclass for handling patches by way of
get_patcher(). -
Updated SCMClients with custom patching behavior are expected to now
subclassPatcherand overridepatcher_clsto match it.
get_patcher()will return it, andapply_patch()will interface
with it. -
SCMClients that override
apply_patch()with legacy patching behavior
will behave as they did before, for now, andget_patcher()will
return a_LegacyPatcherto wrap it. This enablesrbt patchto work
with the legacy implementation.
Over time, we'll remove _LegacyPatcher. We may also be deprecating
apply_patch() soon, once everything is transitioned over.
All unit tests passed.
Applied patches to local trees using both the default patching
implementation and the legacy patcher. Tested applying, reversing,
and committing.