bug 1425215 , bug 1417697 - version bump idempotency that supports relbranches. r=rail

MozReview-Commit-ID: DosTZiDDh8l

--HG--
extra : rebase_source : 9c59a0b8a4633752777ea1f433acfe579b7a6549
extra : source : 565a6a19faa15e210e1c38881f160e0897cc5600
This commit is contained in:
Aki Sasaki 2017-12-15 13:01:39 -06:00
Родитель ada70b6339
Коммит 4d23576876
2 изменённых файлов: 60 добавлений и 1 удалений

Просмотреть файл

@ -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):
"""
"""

Просмотреть файл

@ -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"],