From c07c036c14be01f4858b13b452597a12d686d969 Mon Sep 17 00:00:00 2001 From: Tom Ritter Date: Tue, 18 Oct 2022 16:56:05 +0000 Subject: [PATCH] Bug 1792224: Do some refactoring in preparation for real work r=jewilde If there is a vendoring section missing in the moz.yaml, we will error out. Detect this right away and give a better error. Perform some cleanup since we know we have a vendoring section. Differential Revision: https://phabricator.services.mozilla.com/D158046 --- .../mozbuild/mozbuild/vendor/mach_commands.py | 5 ++ .../mozbuild/vendor/vendor_manifest.py | 64 ++++++++++++------- 2 files changed, 47 insertions(+), 22 deletions(-) diff --git a/python/mozbuild/mozbuild/vendor/mach_commands.py b/python/mozbuild/mozbuild/vendor/mach_commands.py index 7bfadbea1ef9..9bf5db79118c 100644 --- a/python/mozbuild/mozbuild/vendor/mach_commands.py +++ b/python/mozbuild/mozbuild/vendor/mach_commands.py @@ -89,6 +89,11 @@ def vendor( print(e) sys.exit(1) + if "vendoring" not in manifest: + raise Exception( + "Cannot perform update actions if we don't have a 'vendoring' section in the moz.yaml" + ) + if patch_mode and patch_mode not in ["none", "only"]: print( "Unknown patch mode given '%s'. Please use one of: 'none' or 'only'." diff --git a/python/mozbuild/mozbuild/vendor/vendor_manifest.py b/python/mozbuild/mozbuild/vendor/vendor_manifest.py index a111ba2de8e7..b76b8c1daaea 100644 --- a/python/mozbuild/mozbuild/vendor/vendor_manifest.py +++ b/python/mozbuild/mozbuild/vendor/vendor_manifest.py @@ -78,27 +78,7 @@ class VendorManifest(MozbuildObject): self.yaml_file ) - self.source_host = self.get_source_host() - - # Check that updatebot key is available for libraries with existing - # moz.yaml files but missing updatebot information - if "vendoring" in self.manifest: - ref_type = self.manifest["vendoring"]["tracking"] - if revision == "tip": - new_revision, timestamp = self.source_host.upstream_commit("HEAD") - elif ref_type == "tag": - new_revision, timestamp = self.source_host.upstream_tag(revision) - else: - new_revision, timestamp = self.source_host.upstream_commit(revision) - else: - ref_type = "commit" - new_revision, timestamp = self.source_host.upstream_commit(revision) - - self.logInfo( - {"ref_type": ref_type, "ref": new_revision, "timestamp": timestamp}, - "Latest {ref_type} is {ref} from {timestamp}", - ) - + # ========================================================== # If we're only patching; do that if "patches" in self.manifest["vendoring"] and patch_mode == "only": self.import_local_patches( @@ -108,6 +88,26 @@ class VendorManifest(MozbuildObject): ) return + # ========================================================== + self.source_host = self.get_source_host() + + ref_type = self.manifest["vendoring"]["tracking"] + flavor = self.manifest["vendoring"].get("flavor", "regular") + + if revision == "tip": + # This case allows us to force-update a tag-tracking library to master + new_revision, timestamp = self.source_host.upstream_commit("HEAD") + elif ref_type == "tag": + new_revision, timestamp = self.source_host.upstream_tag(revision) + else: + new_revision, timestamp = self.source_host.upstream_commit(revision) + + self.logInfo( + {"ref_type": ref_type, "ref": new_revision, "timestamp": timestamp}, + "Latest {ref_type} is {ref} from {timestamp}", + ) + + # ========================================================== if not force and self.manifest["origin"]["revision"] == new_revision: # We're up to date, don't do anything self.logInfo({}, "Latest upstream matches in-tree.") @@ -117,11 +117,13 @@ class VendorManifest(MozbuildObject): print("%s %s" % (new_revision, timestamp)) return - flavor = self.manifest["vendoring"].get("flavor", "regular") + # ========================================================== if flavor == "regular": self.process_regular( new_revision, timestamp, ignore_modified, add_to_exports ) + elif flavor == "individual-files": + self.process_individual(new_revision, timestamp, ignore_modified) elif flavor == "rust": self.process_rust( command_context, @@ -154,6 +156,24 @@ class VendorManifest(MozbuildObject): self.update_yaml(new_revision, timestamp) + def process_individual(self, new_revision, timestamp, ignore_modified): + + # TBD + + self.update_yaml(new_revision, timestamp) + + self.logInfo({"rev": new_revision}, "Updated to '{rev}'.") + + if "patches" in self.manifest["vendoring"]: + # Remind the user + self.log( + logging.CRITICAL, + "vendor", + {}, + "Patches present in manifest!!! Please run " + "'./mach vendor --patch-mode only' after commiting changes.", + ) + def process_regular(self, new_revision, timestamp, ignore_modified, add_to_exports): if self.should_perform_step("fetch"):