commit 8c5dad81bd8d8914d20c0d114f66a34ea07c9a4c
parent 6d4f3606ee01ab3fdc46acb2e27ca65e6ccf1ec1
Author: Michael Froman <mfroman@mozilla.com>
Date: Fri, 19 Dec 2025 21:33:29 +0000
Bug 2007187 - add git support to restore_elm_arcconfig.py r=dbaker DONTBUILD
Differential Revision: https://phabricator.services.mozilla.com/D277240
Diffstat:
1 file changed, 50 insertions(+), 14 deletions(-)
diff --git a/dom/media/webrtc/third_party_build/restore_elm_arcconfig.py b/dom/media/webrtc/third_party_build/restore_elm_arcconfig.py
@@ -4,7 +4,28 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-from subprocess import run
+import atexit
+import os
+import sys
+
+from run_operations import (
+ ErrorHelp,
+ RepoType,
+ detect_repo_type,
+ run_git,
+ run_shell,
+)
+
+script_name = os.path.basename(__file__)
+error_help = ErrorHelp()
+error_help.set_prefix(f"*** ERROR *** {script_name} did not complete successfully")
+repo_type = detect_repo_type()
+
+
+@atexit.register
+def early_exit_handler():
+ error_help.print_help()
+
# This script sets the Arcanist configuration for the elm repo. This script
# should be run after each repository reset.
@@ -12,18 +33,33 @@ from subprocess import run
# Usage: from the root of the repo `./mach python dom/media/webrtc/third_party_build/restore_elm_arcconfig.py`
#
-ret = run(
- [
- "hg",
- "import",
- "-m",
- "Bug 1729988 - FLOAT - REPO-elm - update .arcconfig repo callsign r=bgrins",
- "dom/media/webrtc/third_party_build/elm_arcconfig.patch",
- ],
- check=False,
-).returncode
-if ret != 0:
- raise Exception(f"Failed to add FLOATing arcconfig patch for ELM: { ret }")
+# first, check which repo we're in, git or hg
+if repo_type is None or not isinstance(repo_type, RepoType):
+ print("Unable to detect repo (git or hg)")
+ sys.exit(1)
+
+commit_msg = "Bug 1729988 - FLOAT - REPO-elm - update .arcconfig repo callsign r=bgrins"
+arc_config_file = "dom/media/webrtc/third_party_build/elm_arcconfig.patch"
+
+error_help.set_help("Failed to add FLOATing arcconfig patch for ELM")
+
+if repo_type == RepoType.GIT:
+ run_git(f"git apply {arc_config_file}", ".")
+ run_git("git add .arcconfig", ".")
+ # use run_shell to avoid run_git's call to split on the cmd string
+ run_shell(f'git commit -m "{commit_msg}" .arcconfig')
+else:
+ # use run_shell to avoid run_hg's call to split on the cmd string
+ run_shell(f"hg import -m '{commit_msg}' {arc_config_file}")
+
+print("ELM .arcconfig restored. Please push this change to ELM:")
+if repo_type == RepoType.GIT:
+ # this command may change when we can test this on the official
+ # twig repo as hosted on git.
+ print(" git push origin master")
else:
- print("ELM .arcconfig restored. Please push this change to ELM:")
print(" hg push -r tip")
+
+# unregister the exit handler so the normal exit doesn't falsely
+# report as an error.
+atexit.unregister(early_exit_handler)