From 7040d4102f0f3915944369e8d25ebf91f6a99640 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Fri, 26 May 2023 15:21:21 +0200 Subject: [PATCH] rename metadata_version to format_version The new name is more accurate. --- src/bootstrap/metrics.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/bootstrap/metrics.rs b/src/bootstrap/metrics.rs index 8aa821a3afc..405a88d7568 100644 --- a/src/bootstrap/metrics.rs +++ b/src/bootstrap/metrics.rs @@ -19,7 +19,7 @@ // Versions: // 0: initial version // 1: replaced JsonNode::Test with JsonNode::TestSuite -const CURRENT_METADATA_VERSION: usize = 1; +const CURRENT_FORMAT_VERSION: usize = 1; pub(crate) struct BuildMetrics { state: RefCell, @@ -151,15 +151,15 @@ pub(crate) fn persist(&self, build: &Build) { // previous invocations are still present in the resulting file. let mut invocations = match std::fs::read(&dest) { Ok(contents) => { - // We first parse just the metadata_version field to have the check succeed even if + // We first parse just the format_version field to have the check succeed even if // the rest of the contents are not valid anymore. - let version: OnlyMetadataVersion = t!(serde_json::from_slice(&contents)); - if version.metadata_version == CURRENT_METADATA_VERSION { + let version: OnlyFormatVersion = t!(serde_json::from_slice(&contents)); + if version.format_version == CURRENT_FORMAT_VERSION { t!(serde_json::from_slice::(&contents)).invocations } else { println!( "warning: overriding existing build/metrics.json, as it's not \ - compatible with build metrics format version {CURRENT_METADATA_VERSION}." + compatible with build metrics format version {CURRENT_FORMAT_VERSION}." ); Vec::new() } @@ -181,8 +181,7 @@ pub(crate) fn persist(&self, build: &Build) { children: steps.into_iter().map(|step| self.prepare_json_step(step)).collect(), }); - let json = - JsonRoot { metadata_version: CURRENT_METADATA_VERSION, system_stats, invocations }; + let json = JsonRoot { format_version: CURRENT_FORMAT_VERSION, system_stats, invocations }; t!(std::fs::create_dir_all(dest.parent().unwrap())); let mut file = BufWriter::new(t!(File::create(&dest))); @@ -234,7 +233,7 @@ struct StepMetrics { #[serde(rename_all = "snake_case")] struct JsonRoot { #[serde(default)] // For version 0 the field was not present. - metadata_version: usize, + format_version: usize, system_stats: JsonInvocationSystemStats, invocations: Vec, } @@ -322,7 +321,7 @@ struct JsonStepSystemStats { } #[derive(Deserialize)] -struct OnlyMetadataVersion { +struct OnlyFormatVersion { #[serde(default)] // For version 0 the field was not present. - metadata_version: usize, + format_version: usize, }