Switch RBTools to use modern patching, and add a legacy patch wrapper.
Review Request #14224 — Created Nov. 3, 2024 and submitted
rbt patch
andrbt land
now use the newPatcher
class
(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 thepatch
tool.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 newPatcher
API and legacy implementations of
SCMClient.apply_patch()
andSCMClient.apply_patch_for_empty_files()
rbt patch
andrbt land
will 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
defaultSCMClientPatcher
class for handling patches by way of
get_patcher()
. -
Updated SCMClients with custom patching behavior are expected to now
subclassPatcher
and overridepatcher_cls
to 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_LegacyPatcher
to wrap it. This enablesrbt patch
to 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.
- Change Summary:
-
Removed unused imports.
- Commits:
-
Summary ID b4e43244593e476e3c2849cf280643296bad0d98 a6694baa951170a39e92f2e614ba5285c0149bfe
Checks run (2 succeeded)
- Change Summary:
-
Added a
SCMClientPatcher
base class for SCMClient-owned patchers. - Description:
-
~ rbt patch
andrbt land
now use the newPatcher
class, which gives~ SCMClients a lot more control over the patching and committing process. ~ rbt patch
andrbt land
now use the newPatcher
class~ (specifically, a SCMClientPatcher
), which gives SCMClients a lot more+ control over the patching and committing process. ~ By default, SCMClients will use their existing patching logic, wrapped
~ by a _LegacyPatcher
implementation that'll be used by default until~ RBTools 7. This acts as a bridge between the new Patcher
API and~ legacy implementations of SCMClient.apply_patch()
and~ SCMClient.apply_patch_for_empty_files()
~ By default, SCMClients that don't define custom patching logic will use
~ the built-in patching logic that leverages the patch
tool.~ ~ 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 new Patcher
API and legacy implementations of+ SCMClient.apply_patch()
andSCMClient.apply_patch_for_empty_files()
rbt patch
andrbt land
will callSCMClient.get_patcher()
to return~ a Patcher
-compatible instance for handling patching operations.~ a SCMClientPatcher
-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 applyingpatches 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
defaultPatcher
class for handling patches by way of
get_patcher()
.
~ -
By default, a SCMClient that doesn't implement custom patching
behavior) will use a defaultapply_patch()
method that gets a
defaultSCMClientPatcher
class for handling patches by way of
get_patcher()
.
-
Updated SCMClients with custom patching behavior are expected to now
subclassPatcher
and overridepatcher_cls
to 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_LegacyPatcher
to wrap it. This enablesrbt patch
to work
with the legacy implementation.
Over time, we'll remove
_LegacyPatcher
. We may also be deprecatingapply_patch()
soon, once everything is transitioned over. -
- Commits:
-
Summary ID a6694baa951170a39e92f2e614ba5285c0149bfe fbfdc1b33f56660d654144653724ec0e85d68c83
- Change Summary:
-
- Fixed an inversed status message ("apply" vs. "revert")
- Fixed a long-standing patching bug where
diff_revision
(used in messages) wouldn't be set from the loaded diff.
- Commits:
-
Summary ID fbfdc1b33f56660d654144653724ec0e85d68c83 795c6d4cf24d4ce942675bf3c0bf51ba04dd304f