llvm_tools: Restructure most patch_manager modes

This is an attempt to gradually replace some of the
behavior of patch_manager.py with a more extendable
structure.

Instead of having the same code handle every patch_manager.py
mode, instead we can have a dispatch for supported modes,
and the fallback to legacy when we can't separate the
existing behavior.

This does not change the external API of patch_manager.py
at all. All unittests still pass, and we're still
applying patches correctly as expected.

BUG=b:188465085, b:227216280
TEST=./patch_manager_unittest.py
TEST=cp patch_manager.py patch_utils.py ${llvm_files}/patch_manager/ \
     && sudo emerge llvm

Change-Id: I43d26d4e903140ce2e490624aaac15d0bae898cd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/3661358
Tested-by: Jordan Abrahams-Whitehead <ajordanr@google.com>
Reviewed-by: George Burgess <gbiv@chromium.org>
Commit-Queue: Jordan Abrahams-Whitehead <ajordanr@google.com>
2 files changed