diff options
author | Jordan R Abrahams <ajordanr@google.com> | 2022-01-19 23:51:36 +0000 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2022-01-22 01:16:33 +0000 |
commit | 86d317a4fdb5f603df849b7056815db5ebe30804 (patch) | |
tree | cdb8d8de13f3585d6471ece3ccdfaab72b498649 | |
parent | f96fffcd3c3bcfa3af9fed129aed3466ee9adc1b (diff) | |
download | toolchain-utils-86d317a4fdb5f603df849b7056815db5ebe30804.tar.gz |
patch_sync: Fix for Rust 1.55 compat, cli patch
On chrotomation, we still use Rust 1.55.
Rust 1.55 does not have the "from" implementation for arrays,
so we must build the BTrees by hand.
Additionally, this removes the requirement for having the
review strings be set.
BUG=b:209493133
TEST=cargo check
Change-Id: I6bc16e96cd56775c8c80667395f3dc3fb4857356
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/3403387
Tested-by: Jordan Abrahams-Whitehead <ajordanr@google.com>
Reviewed-by: George Burgess <gbiv@chromium.org>
Commit-Queue: Jordan Abrahams-Whitehead <ajordanr@google.com>
-rw-r--r-- | llvm_tools/patch_sync/src/main.rs | 18 | ||||
-rw-r--r-- | llvm_tools/patch_sync/src/patch_parsing.rs | 14 |
2 files changed, 18 insertions, 14 deletions
diff --git a/llvm_tools/patch_sync/src/main.rs b/llvm_tools/patch_sync/src/main.rs index 8c1eff1c..033691e4 100644 --- a/llvm_tools/patch_sync/src/main.rs +++ b/llvm_tools/patch_sync/src/main.rs @@ -37,13 +37,14 @@ fn main() -> Result<()> { no_commit, } => transpose_subcmd(TransposeOpt { cros_checkout_path, - cros_reviewers: cros_reviewers.split(',').map(ToOwned::to_owned).collect(), + cros_reviewers: cros_reviewers + .map(|r| r.split(',').map(ToOwned::to_owned).collect()) + .unwrap_or_default(), old_cros_ref, android_checkout_path, android_reviewers: android_reviewers - .split(',') - .map(ToOwned::to_owned) - .collect(), + .map(|r| r.split(',').map(ToOwned::to_owned).collect()) + .unwrap_or_default(), old_android_ref, sync, verbose, @@ -80,8 +81,11 @@ fn show_subcmd(args: ShowOpt) -> Result<()> { parsed_collection } else { filter_patches_by_platform(&parsed_collection, platform).map_patches(|p| { + // Need to do this platforms creation as Rust 1.55 cannot use "from". + let mut platforms = BTreeSet::new(); + platforms.insert(platform.to_string()); PatchDictSchema { - platforms: BTreeSet::from([platform.to_string()]), + platforms, ..p.clone() } }) @@ -230,7 +234,7 @@ enum Opt { /// Emails to send review requests to during Chromium OS upload. /// Comma separated. #[structopt(long = "cros-rev")] - cros_reviewers: String, + cros_reviewers: Option<String>, /// Git ref (e.g. hash) for the ChromiumOS overlay to use as the base. #[structopt(long = "overlay-base-ref")] @@ -243,7 +247,7 @@ enum Opt { /// Emails to send review requests to during Android upload. /// Comma separated. #[structopt(long = "aosp-rev")] - android_reviewers: String, + android_reviewers: Option<String>, /// Git ref (e.g. hash) for the llvm_android repo to use as the base. #[structopt(long = "aosp-base-ref")] diff --git a/llvm_tools/patch_sync/src/patch_parsing.rs b/llvm_tools/patch_sync/src/patch_parsing.rs index 2f0fbc87..581b1899 100644 --- a/llvm_tools/patch_sync/src/patch_parsing.rs +++ b/llvm_tools/patch_sync/src/patch_parsing.rs @@ -253,13 +253,13 @@ pub fn new_patches( let old_collection = old_collection.filter_patches(|p| old_collection.patch_exists(p)); cur_collection.subtract(&old_collection)? }; - let new_patches = new_patches.map_patches(|p| PatchDictSchema { - platforms: BTreeSet::from(["android".to_string(), "chromiumos".to_string()]) - .union(&p.platforms) - .cloned() - .collect(), - - ..p.to_owned() + let new_patches = new_patches.map_patches(|p| { + let mut platforms = BTreeSet::new(); + platforms.extend(["android".to_string(), "chromiumos".to_string()]); + PatchDictSchema { + platforms: platforms.union(&p.platforms).cloned().collect(), + ..p.to_owned() + } }); Ok((cur_collection, new_patches)) } |