• 
      

    Add support for patching using draft diffs in rbt patch.

    Review Request #13153 — Created July 19, 2023 and submitted — Latest diff uploaded

    Information

    RBTools
    release-4.x

    Reviewers

    rbt patch could historically only fetch published diffs, and not draft
    diffs. This meant that a user could not re-download an in-progress patch
    from a review request, and automated build systems could not test or
    inspect diffs prior to publishing.

    This change adds support for fetching draft diffs, when available. There
    are two conditions in which we're fetching a draft diff:

    1. We're fetching the latest diff (default). If found, a draft diff will
      take precedence over any published diffs (as they are the latest),
      and will avoid looking up diff revisions.

    2. We're fetching a specific diff revision (using --diff-revision),
      and the diff revision in question is not published. We'll fetch the
      draft, and if the revision matches, it'll be returned.

    Only the owner of a review request or a special user with the
    can_edit_review_request permission can fetch draft diffs. For other
    users, only published diffs are considered, as normal (this is managed
    by the Review Board API and not RBTools).

    Tested patching/printing the following:

    1. Latest published diffs
    2. Latest draft diff
    3. Specific diff revision of published diff
    4. Specific diff revision of draft diff
    5. Invalid diff revision

    Tested these as the owner, as a user with the special permission, and
    as a standard user, ensuring the correct behavior.

    Commits

    Files