Bug 1492128: [mozrelease] Pass repository to buglist commands; r=mtabara a=release
authorTom Prince <mozilla@hocat.ca>
Tue, 30 Oct 2018 18:21:49 +0000
changeset 501025 c00f4ecec6e7b7dc3867bfad8e116ed18395bc68
parent 501024 45948f09c167c3a3fffe0fa3c86e709fff133c5d
child 501026 06848028132d16f002e1a3b79bf3de157c5f4016
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmtabara, release
bugs1492128
milestone64.0
Bug 1492128: [mozrelease] Pass repository to buglist commands; r=mtabara a=release Differential Revision: https://phabricator.services.mozilla.com/D10156
python/mozrelease/mozrelease/buglist_creator.py
python/mozrelease/mozrelease/mach_commands.py
taskcluster/taskgraph/transforms/release_started.py
--- a/python/mozrelease/mozrelease/buglist_creator.py
+++ b/python/mozrelease/mozrelease/buglist_creator.py
@@ -16,68 +16,69 @@ from mozilla_version.gecko import GeckoV
 
 BUGLIST_PREFIX = 'Bugs since previous changeset: '
 BACKOUT_REGEX = re.compile(r'back(\s?)out|backed out|backing out', re.IGNORECASE)
 BACKOUT_PREFIX = 'Backouts since previous changeset: '
 BUGZILLA_BUGLIST_TEMPLATE = 'https://bugzilla.mozilla.org/buglist.cgi?bug_id={bugs}'
 BUG_NUMBER_REGEX = re.compile(r'bug \d+', re.IGNORECASE)
 CHANGELOG_TO_FROM_STRING = '{product}_{version}_RELEASE'
 CHANGESET_URL_TEMPLATE = (
-    'https://hg.mozilla.org/{release_branch}/{logtype}'
+    '{repo}/{logtype}'
     '?fromchange={from_version}&tochange={to_version}&full=1'
 )
 FULL_CHANGESET_PREFIX = 'Full Mercurial changelog: '
 LIST_DESCRIPTION_TEMPLATE = 'Comparing Mercurial tag {from_version} to {to_version}:'
 MAX_BUGS_IN_BUGLIST = 250
-MERCURIAL_TAGS_URL_TEMPLATE = 'https://hg.mozilla.org/{release_branch}/json-tags'
+MERCURIAL_TAGS_URL_TEMPLATE = '{repo}/json-tags'
 NO_BUGS = ''  # Return this when bug list can't be created
 URL_SHORTENER_TEMPLATE = 'https://bugzilla.mozilla.org/rest/bitly/shorten?url={url}'
 
 log = logging.getLogger(__name__)
 
 
-def create_bugs_url(product, current_version, current_revision):
+def create_bugs_url(product, current_version, current_revision, repo=None):
     """
     Creates list of bugs and backout bugs for release-drivers email
 
     :param release: dict -> containing information about release, from Ship-It
     :return: str -> description of compared releases, with Bugzilla links
         containing all bugs in changeset
     """
     try:
         # Extract the important data, ignore if beta1 release
         if current_version.beta_number == 1:
             # If the version is beta 1, don't make any links
             return NO_BUGS
 
-        branch = get_branch_by_version(current_version)
+        if repo is None:
+            repo = get_repo_by_version(current_version)
         # Get the tag version, for display purposes
         current_version_tag = tag_version(product, current_version)
 
         # Get all Hg tags for this branch, determine the previous version
-        tag_url = MERCURIAL_TAGS_URL_TEMPLATE.format(release_branch=branch)
+        tag_url = MERCURIAL_TAGS_URL_TEMPLATE.format(repo=repo)
         mercurial_tags_json = requests.get(tag_url).json()
         previous_version_tag = get_previous_tag_version(
             product, current_version, current_version_tag, mercurial_tags_json)
 
         # Get the changeset between these versions, parse for all unique bugs and backout bugs
-        resp = requests.get(CHANGESET_URL_TEMPLATE.format(release_branch=branch,
+        resp = requests.get(CHANGESET_URL_TEMPLATE.format(repo=repo,
                                                           from_version=previous_version_tag,
                                                           to_version=current_revision,
                                                           logtype='json-pushes'))
         changeset_data = resp.json()
         unique_bugs, unique_backout_bugs = get_bugs_in_changeset(changeset_data)
 
         # Return a descriptive string with links if any relevant bugs are found
         if unique_bugs or unique_backout_bugs:
             description_string = LIST_DESCRIPTION_TEMPLATE.format(
                 from_version=previous_version_tag,
                 to_version=current_version_tag)
 
-            changeset_html = CHANGESET_URL_TEMPLATE.format(release_branch=branch,
+            changeset_html = CHANGESET_URL_TEMPLATE.format(repo=repo,
                                                            from_version=previous_version_tag,
                                                            to_version=current_revision,
                                                            logtype='pushloghtml')
 
             return format_return_value(
                 description_string, unique_bugs, unique_backout_bugs, changeset_html)
         else:
             return NO_BUGS
@@ -192,47 +193,47 @@ def format_return_value(description, uni
     changeset_full = FULL_CHANGESET_PREFIX + changeset_html
     return_str = '{description}\n{regular_bz_url}{backout_bz_url}{changeset_full}'\
         .format(description=description, regular_bz_url=reg_bugs_link,
                 backout_bz_url=backout_bugs_link, changeset_full=changeset_full)
 
     return return_str
 
 
-def get_branch_by_version(version):
+def get_repo_by_version(version):
     """
-    Get the branch a given version is found on.
+    Get the repo a given version is found on.
     """
     if version.is_beta:
-        return 'releases/mozilla-beta'
+        return 'https://hg.mozilla.org/releases/mozilla-beta'
     elif version.is_release:
-        return 'releases/mozilla-release'
+        return 'https://hg.mozilla.org/releases/mozilla-release'
     elif version.is_esr:
-        return 'releases/mozilla-esr{}'.format(version.major_number)
+        return 'https://hg.mozilla.org/releases/mozilla-esr{}'.format(version.major_number)
     else:
         raise Exception(
             'Unsupported version type {}: {}'.format(
                 version.version_type.name, version))
 
 
 def email_release_drivers(
     addresses, product, version, build_number,
-    revision, task_group_id,
+    repo, revision, task_group_id,
 ):
     # Send an email to the mailing after the build
-    email_buglist_string = create_bugs_url(product, version, revision)
+    email_buglist_string = create_bugs_url(product, version, revision, repo=repo)
 
     content = """\
 A new build has been started:
 
-Commit: https://hg.mozilla.org/{path}/rev/{revision}
+Commit: {repo}/rev/{revision}
 Task group: https://tools.taskcluster.net/push-inspector/#/{task_group_id}
 
 {email_buglist_string}
-""".format(path=get_branch_by_version(version), revision=revision,
+""".format(repo=repo, revision=revision,
            task_group_id=task_group_id,
            email_buglist_string=email_buglist_string)
 
     # On r-d, we prefix the subject of the email in order to simplify filtering
     subject_prefix = ""
     if product in {"fennec"}:
         subject_prefix = "[mobile] "
     if product in {"firefox", "devedition"}:
--- a/python/mozrelease/mozrelease/mach_commands.py
+++ b/python/mozrelease/mozrelease/mach_commands.py
@@ -35,26 +35,29 @@ class MachCommands(MachCommandBase):
                 description="Generate list of bugs since the last release.")
     @CommandArgument('--version',
                      required=True,
                      type=GeckoVersion.parse,
                      help="The version being built.")
     @CommandArgument('--product',
                      required=True,
                      help="The product being built.")
+    @CommandArgument('--repo',
+                     help="The repo being built.")
     @CommandArgument('--revision',
                      required=True,
                      help="The revision being built.")
-    def buglist(self, version, product, revision):
+    def buglist(self, version, product, revision, repo):
         self.setup_logging()
         from mozrelease.buglist_creator import create_bugs_url
         print(create_bugs_url(
             product=product,
             current_version=version,
             current_revision=revision,
+            repo=repo,
         ))
 
     @SubCommand('release', 'send-buglist-email',
                 description="Send an email with the bugs since the last release.")
     @CommandArgument('--address',
                      required=True,
                      action='append',
                      dest='addresses',
@@ -62,16 +65,19 @@ class MachCommands(MachCommandBase):
                           "(may be specified more than once.")
     @CommandArgument('--version',
                      type=GeckoVersion.parse,
                      required=True,
                      help="The version being built.")
     @CommandArgument('--product',
                      required=True,
                      help="The product being built.")
+    @CommandArgument('--repo',
+                     required=True,
+                     help="The repo being built.")
     @CommandArgument('--revision',
                      required=True,
                      help="The revision being built.")
     @CommandArgument('--build-number',
                      required=True,
                      help="The build number")
     @CommandArgument('--task-group-id',
                      help="The task group of the build.")
--- a/taskcluster/taskgraph/transforms/release_started.py
+++ b/taskcluster/taskgraph/transforms/release_started.py
@@ -27,16 +27,17 @@ def add_notifications(config, jobs):
 
         command = [
             'release',
             'send-buglist-email',
             '--version', config.params['version'],
             '--product', job['shipping-product'],
             '--revision', config.params['head_rev'],
             '--build-number', str(config.params['build_number']),
+            '--repo', config.params['head_repository'],
         ]
         for address in emails:
             command += ['--address', address]
         if 'TASK_ID' in os.environ:
             command += [
                 '--task-group-id', os.environ['TASK_ID'],
             ]