# HG changeset patch # User Ian Neal # Date 1588102909 -3600 # Parent 077a9ab664c4c967ec144f2fee452b89f92c96b7 Bug 1633729 - Update about:buildconfig to display comm as well as mozilla source information - use local repo part. r=frg a=frg diff --git a/build/source_repos.py b/build/source_repos.py --- a/build/source_repos.py +++ b/build/source_repos.py @@ -1,35 +1,80 @@ # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. from __future__ import print_function, unicode_literals +import os +import subprocess import sys -import os from datetime import datetime import buildconfig +def get_program_output(*command): + try: + with open(os.devnull) as stderr: + return subprocess.check_output(command, stderr=stderr) + except: + return None + + +def get_repo_info(path): + if os.path.exists(os.path.join(path, '.hg')): + repo = get_program_output('hg', '-R', path, 'paths', 'default') + if repo: + repo = repo.strip() + if repo.startswith('ssh://'): + repo = 'https://' + repo[6:] + repo = repo.rstrip('/') + rev = get_program_output('hg', '-R', path, 'parent', '--template={node}') + return repo, rev + + if os.path.exists(os.path.join(path, '.git')): + cwd = os.getcwd() + os.chdir(path) + rev = None + repo = get_program_output('git', 'config', '--get', 'remote.origin.url') + if repo: + repo = repo.strip() + if repo.startswith('ssh://'): + repo = 'https://' + repo[6:] + repo = repo.rstrip('/.git') + rev = get_program_output('git', 'rev-parse', '--short', 'HEAD') + rev = rev.rstrip('\n') + + os.chdir(cwd) + return repo, rev + + return None, None + + def get_gecko_repo_info(): repo = buildconfig.substs.get('MOZ_GECKO_SOURCE_REPO', None) rev = buildconfig.substs.get('MOZ_GECKO_SOURCE_CHANGESET', None) if not repo: repo = buildconfig.substs.get('MOZ_SOURCE_REPO', None) rev = buildconfig.substs.get('MOZ_SOURCE_CHANGESET', None) - return repo, rev + if repo: + return repo, rev + + return get_repo_info(buildconfig.topsrcdir) def get_comm_repo_info(): repo = buildconfig.substs.get('MOZ_COMM_SOURCE_REPO', None) rev = buildconfig.substs.get('MOZ_COMM_SOURCE_CHANGESET', None) - return repo, rev + if repo: + return repo, rev + + return get_repo_info(os.path.join(buildconfig.topsrcdir, '..')) def get_source_url(repo, rev): source_url = '' if "git" in repo: source_url = '%s/tree/%s' % (repo, rev) else: source_url = '%s/rev/%s' % (repo, rev) diff --git a/configure.in b/configure.in --- a/configure.in +++ b/configure.in @@ -11,24 +11,16 @@ dnl the --with-external-source-dir rules dnl ======================================================== divert(0)dnl #!/bin/sh SRCDIR=$(dirname $0) TOPSRCDIR="$SRCDIR" MOZILLA_SRCDIR="${SRCDIR}/mozilla" export OLD_CONFIGURE="${MOZILLA_SRCDIR}"/old-configure -# Ensure the comm-* values are used unless overridden by environment variables. -if test -z "$MOZ_SOURCE_CHANGESET"; then - export MOZ_SOURCE_CHANGESET=$(hg -R "$TOPSRCDIR" parent --template="{node}" 2>/dev/null) -fi -if test -z "$MOZ_SOURCE_REPO"; then - export MOZ_SOURCE_REPO=$(hg -R "$TOPSRCDIR" showconfig paths.default 2>/dev/null | sed -e "s/^ssh:/https:/") -fi - # If MOZCONFIG isn't set, use the .mozconfig from the current directory. This # overrides the lookup in mozilla-central's configure, which looks in the wrong # directory for this file. if test -z "$MOZCONFIG" -a -f "$SRCDIR"/.mozconfig; then export MOZCONFIG="$SRCDIR"/.mozconfig elif test -z "$MOZCONFIG" -a -f "$SRCDIR"/mozconfig; then export MOZCONFIG="$SRCDIR"/mozconfig fi