diff --git a/testing/mozharness/mozharness/mozilla/repo_manipulation.py b/testing/mozharness/mozharness/mozilla/repo_manipulation.py index 52d3eba612c1..22b258ae56c9 100644 --- a/testing/mozharness/mozharness/mozilla/repo_manipulation.py +++ b/testing/mozharness/mozharness/mozilla/repo_manipulation.py @@ -1,4 +1,5 @@ import ConfigParser +import json import os from mozharness.base.errors import HgErrorList @@ -138,6 +139,24 @@ class MercurialRepoManipulationMixin(object): error_list=HgErrorList ) + def query_existing_tags(self, cwd, halt_on_failure=True): + cmd = self.query_exe('hg', return_type='list') + ['tags'] + existing_tags = {} + output = self.get_output_from_command( + cmd, cwd=cwd, halt_on_failure=halt_on_failure + ) + for line in output.splitlines(): + parts = line.split(' ') + if len(parts) > 1: + # existing_tags = {TAG: REVISION, ...} + existing_tags[parts[0]] = parts[-1].split(':')[-1] + self.info( + "existing_tags:\n{}".format( + json.dumps(existing_tags, sort_keys=True, indent=4) + ) + ) + return existing_tags + def push(self): """ """ diff --git a/testing/mozharness/scripts/release/postrelease_version_bump.py b/testing/mozharness/scripts/release/postrelease_version_bump.py index b06aca9f4187..ddc6542b9918 100644 --- a/testing/mozharness/scripts/release/postrelease_version_bump.py +++ b/testing/mozharness/scripts/release/postrelease_version_bump.py @@ -16,6 +16,7 @@ import sys sys.path.insert(1, os.path.dirname(os.path.dirname(sys.path[0]))) from mozharness.base.vcs.vcsbase import MercurialScript +from mozharness.base.vcs.mercurial import MercurialVCS from mozharness.mozilla.buildbot import BuildbotMixin from mozharness.mozilla.repo_manipulation import MercurialRepoManipulationMixin @@ -152,8 +153,18 @@ class PostReleaseVersionBump(MercurialScript, BuildbotMixin, return ["-e", hg_ssh_opts, "-r", "."] def pull(self): + dirs = self.query_abs_dirs() + # bug 1417697 - clone default first, then pull to get the revision. + # This to deal with relbranches, which don't show up in mozilla-unified. super(PostReleaseVersionBump, self).pull( repos=self.query_repos()) + vcs_obj = MercurialVCS(log_obj=self.log_obj, config=self.config) + vcs_obj.pull( + self.config['repo']['repo'], + dirs['abs_gecko_dir'], + update_dest=False, + revision=self.config['revision'] + ) def bump_postrelease(self, *args, **kwargs): """Bump version""" @@ -162,13 +173,38 @@ class PostReleaseVersionBump(MercurialScript, BuildbotMixin, curr_version = ".".join(self.get_version(dirs['abs_gecko_dir'], f["file"])) next_version = self.config['next_version'] - if StrictVersion(next_version) <= StrictVersion(curr_version): + if StrictVersion(next_version) < StrictVersion(curr_version): self.warning("Version bumping skipped due to conflicting values") continue + elif StrictVersion(next_version) == StrictVersion(curr_version): + self.info("Version bumping skipped due to unchanged values") + continue else: self.replace(os.path.join(dirs['abs_gecko_dir'], f["file"]), curr_version, self.config["next_version"]) + def check_tags(self, tag_names): + dirs = self.query_abs_dirs() + existing_tags = self.query_existing_tags(cwd=dirs['abs_gecko_dir']) + tags = [] + for tag in tag_names: + if tag in existing_tags: + if self.config['revision'] == existing_tags[tag]: + self.info( + "Tag {} already exists on revision {}. Skipping...".format( + tag, self.config['revision'] + ) + ) + continue + else: + self.warning( + "Tag {} exists on mismatched revision {}! Retagging...".format( + tag, existing_tags[tag] + ) + ) + tags.append(tag) + return tags + def tag(self): dirs = self.query_abs_dirs() tags = ["{product}_{version}_BUILD{build_number}", @@ -177,6 +213,10 @@ class PostReleaseVersionBump(MercurialScript, BuildbotMixin, version=self.config["version"].replace(".", "_"), build_number=self.config["build_number"]) for t in tags] + tags = self.check_tags(tags) + if not tags: + self.info("No unique tags to add; skipping tagging.") + return message = "No bug - Tagging {revision} with {tags} a=release CLOSED TREE" message = message.format( revision=self.config["revision"],