Add empty file handling in JujutsuPatcher.
Review Request #14760 — Created Jan. 6, 2026 and updated
In my previous change that updated the patching infrastructure to add
support for patching binary files, I changed the top-level Patcher class
so it would (when supported) callapply_patch_for_empty_files. This
caused a regression with Jujutsu, where we had no implementation of
that. I didn't catch this because it was hidden behind a conditional
which was false in the case of unit tests, since we weren't
instantiating the client with a capabilities object.This change adds an implementation of that method for Jujutsu which
works similar to the SVN and Perforce implementations. Mercurial and Git
are otherwise immune because they use SCM-native patching which handles
empty files itself (hg importandgit apply, respectively).Some of the jj unit tests were incorrectly named, saying they included
empty files when they didn't. I've fixed those up, deleted a test which
did not do anything unique, and added two new tests similar to ones we
have inGitPatcherTestsfor ensuring that empty files work correctly.To be complete, I've also added the default capabilities object to the
Git, Mercurial, and Perforce tests, just to ensure that the result of
supports_empty_files()will be correct when running the tests.
Ran unit tests.
| Summary | ID |
|---|---|
| zyloxzouusozptwmwyrvtswmorwxovus |
| Description | From | Last Updated |
|---|---|---|
|
continuation line over-indented for visual indent Column: 64 Error code: E127 |
|
|
|
blank line at end of file Column: 1 Error code: W391 |
|
|
|
This should say "deleted empty files" |
|
|
|
What raises this? |
|
|
|
Blank line between these. |
|
|
|
We're decoding multiple times, which is a bit wasteful. We should decode in a separate step, or an internal comprehension: … |
|
|
|
Blank line here. |
|
|
|
Blank line here. |
|
|
|
This log should probably include the filename in quotes followed by the error message. |
|
|
|
No trailing period here. |
|
|
|
Blank line between statements and blocks. |
|
|
|
We don't normally do an explicit mode=, just leaving it as positional. Here and below. |
|
|
|
The second keyword argument should be on its own line. |
|
|
|
No trailing period here. |
|
|
|
Blank line between statements and blocks. |
|
|
|
Same comment re: one keyword argument per line. |
|
|
|
Blank line here. |
|
|
|
Is there a chance that one file deletion fails, but the others succeed? In that case we'd return True from … |
|