• 
      

    Add Perforce binary file patching and fix up existing patch issues.

    Review Request #14722 — Created Dec. 3, 2025 and submitted — Latest diff uploaded

    Information

    RBTools
    master

    Reviewers

    This change adds support to the PerforceParser for applying binary
    files as part of changes. The most basic part of this is just the
    implementation of the add/move/delete methods, but while working on this
    I discovered that patching for Perforce was broken in a variety of ways:

    • We've traditionally relied on the patch command to handle opening
      the relevant files, and we still do, but it now opens and edits them
      in a way which requires running p4 reconcile. This command has been
      added to the end of the patch sequence.

    • apply_patch_for_empty_files would use a regex to pull out filenames
      from the diff that then got passed to p4 add or p4 delete, but
      that regex only stripped off a leading "//" and did not map filenames
      to client names. It seems like in some cases Perforce was clever
      enough to know that "depot/something/..." really meant
      "//depot/something/...", but that depended highly on what that depot
      was called and what the client mapping was set up to look like. I've
      changed it to map the depot filenames to local first.

    • apply_patch_for_empty_files was only being called in the case that
      the patch entirely failed to apply, meaning we had a change that
      comprised only empty files. Patches with a mix of empty and
      non-empty file changes would apply the non-empty ones and skip the
      rest. The fix for this issue is actually inside /r/14711, which
      reorganizes the top-level patching process to always call this method
      when needed.

    • Ran unit tests.
    • Applied a variety of patches that included mixes of empty, non-empty,
      and binary files.

    Commits

    Files