bug 746277: replace hg commands with functions
authorJoey Armstrong <joey@mozilla.com>
Fri, 15 Feb 2013 17:00:12 -0500
changeset 122070 f4cffc9cafba885b9111d5f397a616b87837fea2
parent 122069 49567747a7609cd2ec4374e016f43546fd740fd7
child 122071 9f5df013993016e29cb59ce8284a33213bc461b3
push id24317
push userryanvm@gmail.com
push dateSat, 16 Feb 2013 14:49:39 +0000
treeherdermozilla-central@484dbca61133 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs746277
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 746277: replace hg commands with functions
b2g/app/Makefile.in
build/Makefile.in
config/makefiles/makeutils.mk
config/makefiles/rcs.mk
js/src/config/makefiles/makeutils.mk
js/src/config/makefiles/rcs.mk
toolkit/content/Makefile.in
toolkit/mozapps/installer/package-name.mk
toolkit/xre/Makefile.in
--- a/b2g/app/Makefile.in
+++ b/b2g/app/Makefile.in
@@ -3,16 +3,18 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 DEPTH     = @DEPTH@
 topsrcdir = @top_srcdir@
 srcdir    = @srcdir@
 VPATH     = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
+USE_RCS_MK := 1
+include $(topsrcdir)/config/makefiles/rcs.mk
 
 PREF_JS_EXPORTS = $(srcdir)/b2g.js
 
 ifdef ENABLE_MARIONETTE
 DEFINES += -DENABLE_MARIONETTE=1
 endif
 
 ifndef LIBXUL_SDK
@@ -71,25 +73,19 @@ include $(topsrcdir)/config/rules.mk
 APP_ICON = b2g
 
 DEFINES += \
   -DAPP_NAME=$(MOZ_APP_NAME) \
   -DAPP_VERSION=$(MOZ_APP_VERSION) \
   -DMOZ_UPDATER=$(MOZ_UPDATER) \
   $(NULL)
 
-# strip a trailing slash from the repo URL because it's not always present,
-# and we want to construct a working URL in buildconfig.html
-# make+shell+sed = awful
-_dollar=$$
-SOURCE_REPO := $(shell cd $(srcdir)/.. && hg showconfig paths.default 2>/dev/null | head -n1 | sed -e "s/^ssh:/http:/" -e "s/\/$(_dollar)//" )
-# extra sanity check for old versions of hg
-# that don't support showconfig
-ifeq (http,$(patsubst http%,http,$(SOURCE_REPO)))
-DEFINES += -DMOZ_SOURCE_REPO="$(SOURCE_REPO)"
+source_repo ?= $(call getSourceRepo,$(srcdir)/..)
+ifneq (,$(filter http%,$(source_repo)))
+  DEFINES += -DMOZ_SOURCE_REPO="$(source_repo)"
 endif
 
 ifeq ($(OS_ARCH),WINNT)
 REDIT_PATH = $(LIBXUL_DIST)/bin
 endif
 
 APP_BINARY = $(MOZ_APP_NAME)$(BIN_SUFFIX)
 
--- a/build/Makefile.in
+++ b/build/Makefile.in
@@ -4,16 +4,18 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 DEPTH		= @DEPTH@
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
+USE_RCS_MK := 1
+include $(topsrcdir)/config/makefiles/makeutils.mk
 
 MODULE = build
 
 ifeq (,$(filter WINNT OS2,$(OS_ARCH)))
 DIRS		= unix
 endif
 
 ifeq (WINNT,$(OS_ARCH))
@@ -58,20 +60,19 @@ DEFINES += -DGRE_MILESTONE=$(GRE_MILESTO
 DEFINES += -DMOZ_APP_VERSION="$(MOZ_APP_VERSION)"
 APP_INI_DEPS += $(DEPTH)/config/autoconf.mk
 
 MOZ_SOURCE_STAMP := $(firstword $(shell cd $(topsrcdir)/$(MOZ_BUILD_APP)/.. && hg parent --template="{node|short}\n" 2>/dev/null))
 ifdef MOZ_SOURCE_STAMP
 DEFINES += -DMOZ_SOURCE_STAMP="$(MOZ_SOURCE_STAMP)"
 endif
 
-_dollar=$$
-SOURCE_REPO := $(shell cd $(topsrcdir)/$(MOZ_BUILD_APP)/.. && hg showconfig paths.default 2>/dev/null | head -n1 | sed -e "s/^ssh:/http:/" -e "s/\/$(_dollar)//" )
-ifdef SOURCE_REPO
-DEFINES += -DMOZ_SOURCE_REPO="$(SOURCE_REPO)"
+source_repo ?= $(call getSourceRepo,$(topsrcdir)/$(MOZ_BUILD_APP)/..)
+ifneq (,$(source_repo))
+  DEFINES += -DMOZ_SOURCE_REPO="$(source_repo)"
 endif
 
 DEFINES += \
   -DMOZ_APP_BASENAME="$(MOZ_APP_BASENAME)" \
   -DMOZ_APP_VENDOR="$(MOZ_APP_VENDOR)" \
   -DMOZ_APP_ID="$(MOZ_APP_ID)" \
   -DMAR_CHANNEL_ID="$(MAR_CHANNEL_ID)" \
   -DACCEPTED_MAR_CHANNEL_IDS="$(ACCEPTED_MAR_CHANNEL_IDS)" \
--- a/config/makefiles/makeutils.mk
+++ b/config/makefiles/makeutils.mk
@@ -108,10 +108,14 @@ endif #}
 ## Common makefile library loader
 ###########################################################################
 topORerr =$(if $(topsrcdir),$(topsrcdir),$(error topsrcdir is not defined))
 
 ifdef USE_AUTOTARGETS_MK # mkdir_deps
   include $(topORerr)/config/makefiles/autotargets.mk
 endif
 
+ifdef USE_RCS_MK
+  include $(topORerr)/config/makefiles/rcs.mk
+endif
+
 ## copy(src, dst): recursive copy
 copy_dir = (cd $(1)/. && $(TAR) $(TAR_CREATE_FLAGS_QUIET) - .) | (cd $(2)/. && tar -xf -)
new file mode 100644
--- /dev/null
+++ b/config/makefiles/rcs.mk
@@ -0,0 +1,42 @@
+# -*- makefile -*-
+# vim:set ts=8 sw=8 sts=8 noet:
+#
+# 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/.
+#
+
+ifdef USE_RCS_MK #{
+
+ifndef INCLUDED_RCS_MK #{
+
+MOZ_RCS_TYPE ?= $(notdir $(wildcard $(topsrcdir)/.hg))
+
+
+###########################################################################
+# HAVE_MERCURIAL_RCS
+###########################################################################
+ifeq (.hg,$(MOZ_RCS_TYPE)) #{
+
+# Intent: Retrieve the http:// repository path for a directory.
+# Usage: $(call getSourceRepo[,repo_dir|args])
+# Args:
+#   path (optional): repository to query.  Defaults to $(topsrcdir)
+getSourceRepo = \
+  $(call FUNC_getSourceRepo,$(if $(1),cd $(1) && hg,hg --repository $(topsrcdir)))
+
+# return: http://hg.mozilla.org/mozilla-central
+FUNC_getSourceRepo = \
+  $(strip \
+    $(patsubst %/,%,\
+    $(patsubst ssh://%,http://%,\
+    $(firstword $(shell $(getargv) showconfig paths.default))\
+    )))
+
+endif #} HAVE_MERCURIAL_RCS
+
+
+INCLUDED_RCS_MK := 1
+endif #}
+
+endif #}
--- a/js/src/config/makefiles/makeutils.mk
+++ b/js/src/config/makefiles/makeutils.mk
@@ -108,10 +108,14 @@ endif #}
 ## Common makefile library loader
 ###########################################################################
 topORerr =$(if $(topsrcdir),$(topsrcdir),$(error topsrcdir is not defined))
 
 ifdef USE_AUTOTARGETS_MK # mkdir_deps
   include $(topORerr)/config/makefiles/autotargets.mk
 endif
 
+ifdef USE_RCS_MK
+  include $(topORerr)/config/makefiles/rcs.mk
+endif
+
 ## copy(src, dst): recursive copy
 copy_dir = (cd $(1)/. && $(TAR) $(TAR_CREATE_FLAGS_QUIET) - .) | (cd $(2)/. && tar -xf -)
new file mode 100644
--- /dev/null
+++ b/js/src/config/makefiles/rcs.mk
@@ -0,0 +1,42 @@
+# -*- makefile -*-
+# vim:set ts=8 sw=8 sts=8 noet:
+#
+# 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/.
+#
+
+ifdef USE_RCS_MK #{
+
+ifndef INCLUDED_RCS_MK #{
+
+MOZ_RCS_TYPE ?= $(notdir $(wildcard $(topsrcdir)/.hg))
+
+
+###########################################################################
+# HAVE_MERCURIAL_RCS
+###########################################################################
+ifeq (.hg,$(MOZ_RCS_TYPE)) #{
+
+# Intent: Retrieve the http:// repository path for a directory.
+# Usage: $(call getSourceRepo[,repo_dir|args])
+# Args:
+#   path (optional): repository to query.  Defaults to $(topsrcdir)
+getSourceRepo = \
+  $(call FUNC_getSourceRepo,$(if $(1),cd $(1) && hg,hg --repository $(topsrcdir)))
+
+# return: http://hg.mozilla.org/mozilla-central
+FUNC_getSourceRepo = \
+  $(strip \
+    $(patsubst %/,%,\
+    $(patsubst ssh://%,http://%,\
+    $(firstword $(shell $(getargv) showconfig paths.default))\
+    )))
+
+endif #} HAVE_MERCURIAL_RCS
+
+
+INCLUDED_RCS_MK := 1
+endif #}
+
+endif #}
--- a/toolkit/content/Makefile.in
+++ b/toolkit/content/Makefile.in
@@ -7,16 +7,18 @@
 DEPTH     = @DEPTH@
 topsrcdir = @top_srcdir@
 srcdir    = @srcdir@
 VPATH     = @srcdir@
 
 CHROME_DEPS = buildconfig.html
 
 include $(DEPTH)/config/autoconf.mk
+USE_RCS_MK := 1
+include $(topsrcdir)/config/makefiles/makeutils.mk
 
 DEFINES += \
   -Dtarget="$(target)" \
   -Dac_configure_args="$(ac_configure_args)" \
   -DCC="$(CC)" \
   -DCC_VERSION="$(CC_VERSION)" \
   -DCFLAGS="$(CFLAGS)" \
   -DCXX="$(CXX)" \
@@ -31,25 +33,19 @@ MOZ_SOURCE_STAMP ?= $(shell hg -R $(tops
 ifdef MOZ_SOURCE_STAMP
 DEFINES += -DSOURCE_CHANGESET="$(MOZ_SOURCE_STAMP)"
 endif
 
 ifeq (Android,$(OS_TARGET))
 DEFINES += -DANDROID_PACKAGE_NAME=$(ANDROID_PACKAGE_NAME)
 endif
 
-# strip a trailing slash from the repo URL because it's not always present,
-# and we want to construct a working URL in buildconfig.html
-# make+shell+sed = awful
-_dollar=$$
-SOURCE_REPO := $(shell cd $(topsrcdir) && hg showconfig paths.default 2>/dev/null | head -n1 | sed -e "s/^ssh:/http:/" -e "s/\/$(_dollar)//" )
-# extra sanity check for old versions of hg
-# that don't support showconfig
-ifeq (http,$(patsubst http%,http,$(SOURCE_REPO)))
-DEFINES += -DSOURCE_REPO="$(SOURCE_REPO)"
+source_repo ?= $(call getSourceRepo)
+ifneq (,$(filter http%,$(source_repo)))
+  DEFINES += -DSOURCE_REPO="$(source_repo)"
 endif
 
 BUILD_HOSTNAME = $(shell hostname -s || hostname)
 DEFINES += -DBUILD_HOSTNAME="$(BUILD_HOSTNAME)"
 
 ifdef MOZ_TOOLKIT_SEARCH
 DEFINES += -DMOZ_TOOLKIT_SEARCH
 endif
--- a/toolkit/mozapps/installer/package-name.mk
+++ b/toolkit/mozapps/installer/package-name.mk
@@ -133,22 +133,27 @@ SYMBOL_ARCHIVE_BASENAME = $(PKG_BASENAME
 TEST_PACKAGE = $(PKG_BASENAME).tests.zip
 
 ifneq (,$(wildcard $(DIST)/bin/application.ini))
 BUILDID = $(shell $(PYTHON) $(MOZILLA_DIR)/config/printconfigsetting.py $(DIST)/bin/application.ini App BuildID)
 else
 BUILDID = $(shell $(PYTHON) $(MOZILLA_DIR)/config/printconfigsetting.py $(DIST)/bin/platform.ini Build BuildID)
 endif
 
+ifndef INCLUDED_RCS_MK
+  USE_RCS_MK := 1
+  include $(topsrcdir)/config/makefiles/makeutils.mk
+endif
+
 MOZ_SOURCE_STAMP = $(firstword $(shell hg -R $(MOZILLA_DIR) parent --template="{node|short}\n" 2>/dev/null))
 
-# strip a trailing slash from the repo URL because it's not always present,
-# and we want to construct a working URL in the sourcestamp file.
-# make+shell+sed = awful
-_dollar=$$
-MOZ_SOURCE_REPO = $(shell cd $(MOZILLA_DIR) && hg showconfig paths.default 2>/dev/null | head -n1 | sed -e "s/^ssh:/http:/" -e "s/\/$(_dollar)//" )
+###########################################################################
+# bug: 746277 - preserve existing functionality.
+# MOZILLA_DIR="": cd $(SPACE); hg # succeeds if ~/.hg exists
+###########################################################################
+MOZ_SOURCE_REPO = $(call getSourceRepo,$(MOZILLA_DIR)$(NULL) $(NULL))
 
 MOZ_SOURCESTAMP_FILE = $(DIST)/$(PKG_PATH)/$(MOZ_SOURCESTAMP_FILE_BASENAME).txt
 
 # JavaScript Shell
 PKG_JSSHELL = $(DIST)/jsshell-$(MOZ_PKG_PLATFORM).zip
 
 endif # PACKAGE_NAME_MK_INCLUDED
--- a/toolkit/xre/Makefile.in
+++ b/toolkit/xre/Makefile.in
@@ -7,16 +7,19 @@
 
 DEPTH     = @DEPTH@
 topsrcdir = @top_srcdir@
 srcdir    = @srcdir@
 VPATH     = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
+USE_RCS_MK=1
+include $(topsrcdir)/config/makefiles/makeutils.mk
+
 milestone_txt = $(topsrcdir)/config/milestone.txt
 
 MODULE = xulapp
 LIBRARY_NAME = xulapp_s
 LIBXUL_LIBRARY = 1
 
 FORCE_STATIC_LIB = 1
 
@@ -210,30 +213,21 @@ DEFINES += -DHAVE_USR_LIB64_DIR
 endif
 endif
 
 MOZ_SOURCE_STAMP ?= $(firstword $(shell hg -R $(topsrcdir) parent --template="{node|short}\n" 2>/dev/null))
 ifdef MOZ_SOURCE_STAMP
 
   INIARGS = --sourcestamp=$(MOZ_SOURCE_STAMP)
 
-  # strip a trailing slash from the repo URL because it's not always present,
-  # and we want to construct a working URL in buildconfig.html
-  SOURCE_REPO := $(firstword $(shell hg --repository $(topsrcdir) showconfig paths.default 2>/dev/null))
-  SOURCE_REPO := $(strip $(SOURCE_REPO))
-  SOURCE_REPO := $(patsubst ssh://%,http://%,$(SOURCE_REPO))
-  SOURCE_REPO := $(patsubst %/,%,$(SOURCE_REPO))
-
-  # command set should change based on revision control use.
-  # warn for now in case (git, bzr, ...) is in use.
-  $(call warnIfEmpty,SOURCE_REPO) 
+  source_repo := $(call getSourceRepo)
 
   # extra sanity check for old versions of hg, no showconfig support
-  ifeq (http,$(patsubst http%,http,$(SOURCE_REPO)))
-    INIARGS += --sourcerepo=$(SOURCE_REPO)
+  ifneq (,$(filter http%,$(source_repo)))
+    INIARGS += --sourcerepo=$(source_repo)
   endif
 
 endif # MOZ_SOURCE_STAMP
 
 GRE_MILESTONE := $(strip $(lastword $(shell cat $(milestone_txt) 2>/dev/null)))
 GRE_BUILDID   := $(strip $(firstword $(shell cat $(DEPTH)/config/buildid 2>/dev/null)))
 $(call errorIfEmpty,GRE_MILESTONE GRE_BUILDID)