Fix up bugs in `rbt patch` with old-style review requests.

Review Request #10933 — Created March 2, 2020 and submitted — Latest diff uploaded

Information

RBTools
release-2.0.x

Reviewers

The new rbt patch implementation did a pretty good job of applying
commits from new-style review requests that have multi-commit history,
but it broke with old review requests that just have single diffs. This
change fixes up the issues I ran into:

  • The code was never populating the commits list, unless --squashed
    was given. It then would always use commits[0], blowing up. I've
    changed it to fetch the full diff data when there are no commits.
  • When --squashed was specified, we'd end up passing expand=None to
    the API request, which would then blow up.
  • The code that determined whether to create the commit wasn't working
    properly with --squashed, because it was testing patch_num as if it
    was 0-indexed when in fact it's 1-indexed.
  • Was able to apply patches from review requests without commit history.
  • Was able to apply patches using --squashed
  • Ran unit tests (there are some problems with the test suite right now
    but those are unrelated to anything touched here).

Commits

Files