mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 16:25:38 +00:00
02a7b4ebdf
Allow-list all Python code in tree for use with the black linter, and re-format all code in-tree accordingly. To produce this patch I did all of the following: 1. Make changes to tools/lint/black.yml to remove include: stanza and update list of source extensions. 2. Run ./mach lint --linter black --fix 3. Make some ad-hoc manual updates to python/mozbuild/mozbuild/test/configure/test_configure.py -- it has some hard-coded line numbers that the reformat breaks. 4. Make some ad-hoc manual updates to `testing/marionette/client/setup.py`, `testing/marionette/harness/setup.py`, and `testing/firefox-ui/harness/setup.py`, which have hard-coded regexes that break after the reformat. 5. Add a set of exclusions to black.yml. These will be deleted in a follow-up bug (1672023). # ignore-this-changeset Differential Revision: https://phabricator.services.mozilla.com/D94045
68 lines
1.9 KiB
Python
68 lines
1.9 KiB
Python
#! /usr/bin/env python3
|
|
# 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/.
|
|
|
|
assert __name__ != "__main__"
|
|
|
|
"""
|
|
Any time we vendor[1] from an external git repo, we want to keep a record of the csets
|
|
we're pulling from.
|
|
|
|
This script leaves a record of the merge-base reference tip and cherry-picks that we pull
|
|
into Gecko. (such as gfx/angle/cherry_picks.txt)
|
|
"""
|
|
|
|
from pathlib import *
|
|
import subprocess
|
|
import sys
|
|
|
|
# --
|
|
|
|
|
|
def print_now(*args):
|
|
print(*args)
|
|
sys.stdout.flush()
|
|
|
|
|
|
def run_checked(*args, **kwargs):
|
|
print(" ", args)
|
|
sys.stdout.flush()
|
|
return subprocess.run(args, check=True, **kwargs)
|
|
|
|
|
|
# --
|
|
|
|
|
|
def record_cherry_picks(dir_in_gecko, merge_base_origin):
|
|
# merge_base_origin is not always 'origin'!
|
|
merge_base_from = Path(dir_in_gecko, "MERGE_BASE").read_text().split("\n")[0]
|
|
merge_base_from = merge_base_origin + "/" + merge_base_from
|
|
|
|
assert "/" in merge_base_from, "Please specify a reference tip from a remote."
|
|
log_path = Path(dir_in_gecko, "cherry_picks.txt")
|
|
print_now("Logging cherry picks to {}.".format(log_path))
|
|
|
|
merge_base = (
|
|
run_checked(
|
|
"git", "merge-base", "HEAD", merge_base_from, stdout=subprocess.PIPE
|
|
)
|
|
.stdout.decode()
|
|
.strip()
|
|
)
|
|
|
|
mb_info = run_checked(
|
|
"git", "log", "{}~1..{}".format(merge_base, merge_base), stdout=subprocess.PIPE
|
|
).stdout
|
|
cherries = run_checked(
|
|
"git", "log", merge_base + "..", stdout=subprocess.PIPE
|
|
).stdout
|
|
|
|
with open(log_path, "wb") as f:
|
|
f.write(cherries)
|
|
f.write(b"\nCherries picked")
|
|
f.write(b"\n" + (b"=" * 80))
|
|
f.write(b"\nMerge base from: " + merge_base_from.encode())
|
|
f.write(b"\n\n")
|
|
f.write(mb_info)
|