llvm_tools: Retain indent style for PATCHES.json

At present, patch_utils.py and get_upstream_patch.py enforce
a spacing style of 4 spaces per indentation level. However,
cros format requires an indentation style of 2 spaces per
indentation level. This alters the tooling so that they preserve
the indentation level of the existing file.

The implementation here isn't as clean as in patch_sync, but
it achieves reliable results. Existing patch_utils testing
covers this new function already.

BUG=b:265348099
TEST=./patch_utils_unittest; ./patch_manager_unittest.py
TEST=Ran get_upstream_patch.py before/after cros format
TEST=build llvm

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