Add infrastructure for binary file patching in rbt patch.
Review Request #14711 — Created Nov. 28, 2025 and updated
This adds the core infrastructure needed to support binary file patching
when applying review request diffs usingrbt patch.
rbtools.diffs.patches.BinaryFilePatchrepresents binary files in the
diff, and can lazily load their content as-needed.
rbtools.diffs.patcher.Patchernow has several methods to apply binary
files in various ways. They can be overridden by SCM-specific patchers
to perform file operations as necessary.
rbtools.diffs.patches.PatchResultwill now track which binary files
were applied (or failed).The
rbt patchcommand has been updated to:
- Fetch binary file metadata from diff and commit resources.
- Pass binary files to
Patchinstances. - Report binary file application results
- Add the new
--no-binaryoption, which skips patching binary files.
Subsequent changes will add support for individual SCM systems.
- Ran unit tests.
- Used this in conjunction with later changes to actually apply patches
that include binary files.
| Summary | ID |
|---|---|
| mxnmkxtkuwpysslkkonvosuyumspvzsx |
| Description | From | Last Updated |
|---|---|---|
|
Since this is only used here internally, it might be worth just letting this live in TYPE_CHECKING. |
|
|
|
Can you add double-backticks around this and a period? |
|
|
|
Missing a period. |
|
|
|
This might be a bit easier to follow if we remove a level of nesting, like: if p_num == 0: … |
|
|
|
This is a small regex. Might just be worth defining it once globally instead of per-class. Otherwise, if we're likely … |
|
|
|
Can we make reverted keyword-only? Same with the other similar methods. |
|
|
|
Should this be Sequence? |
|
|
|
Missing parens around the union. |
|
|
|
Missing a trailing period. |
|
|
|
Missing a blank line before the if. |
|
|
|
This is going to overwrite binary_files_applied each time, preserving only the last filename. append() might be the right thing, but … |
|
|
|
Similar issue with json.add. It's going to overwrite each time. |
|
|
|
We could do a walrus operator here so we don't have to access patch.binary_files twice. |
|
|
|
We're inconsistent with localization in RBTools. We probably should work toward localizing all new strings. I just picked one example, … |
|
|
|
This sort of reads like "add a file (to the patcher)", but it's really "handle a file add". I wonder … |
|
|
|
This needs a Version Added. Same with the functions below. |
|
|
|
Can we call this fp, so it's consistent with most other open calls? Other file information objects in this change … |
|
|
|
To keep this in alphabetical order, these should be swapped. |
|
|
|
Should we make a TypeAlias for this? |
|
|
|
Missing 'moved'. |
|
|
|
These comments are missing trailing periods. |
|
|
|
Missing period. Same with others in the file. |
|
|
|
Missing period and blank line. |
|
|
|
Can we stick to one per line? |
|
|
|
Can we make these keyword-only? |
|
|
|
This needs a Version Added. |
|
|
|
It's not really clear what this is ultimately doing. Maybe worth just making a function for this? |
|
|
|
line too long (81 > 79 characters) Column: 80 Error code: E501 |
|
|
|
line too long (87 > 79 characters) Column: 80 Error code: E501 |
|
- Change Summary:
-
Add a utility function for testing binary file patch downloads.
- Commits:
-
Summary ID mxnmkxtkuwpysslkkonvosuyumspvzsx mxnmkxtkuwpysslkkonvosuyumspvzsx
Checks run (2 succeeded)
-
-
-
-
This might be a bit easier to follow if we remove a level of nesting, like:
if p_num == 0: return file_or_files # Rest here -
This is a small regex. Might just be worth defining it once globally instead of per-class.
Otherwise, if we're likely to access this more than we set it, this can just be a
try/except, catchingAttributeError. -
-
-
-
-
This is going to overwrite
binary_files_appliedeach time, preserving only the last filename.append()might be the right thing, but I think you probably just want:self.json.add('binary_files_applied', patch_result.binary_applied) -
-
We're inconsistent with localization in RBTools. We probably should work toward localizing all new strings. I just picked one example, but this applies more generally.
-
This sort of reads like "add a file (to the patcher)", but it's really "handle a file add". I wonder if we should call this
handle_add_file()? Same thought for move/remove/write. -
-
Can we call this
fp, so it's consistent with most otheropencalls? Other file information objects in this change usef. -
-
-
-
-
-
-
-