Files
chromium_depot_tools/infra_to_superproject.py
Mike Frysinger 124bb8e53c switch to 4 space indent
Leave the recipes/ code at 2 space to match the rest of the recipes
project in other repos.

Reformatted using:
files=( $(
	git ls-tree -r --name-only HEAD | \
		grep -Ev -e '^(third_party|recipes)/' | \
		grep '\.py$';
	git grep -l '#!/usr/bin/env.*python' | grep -v '\.py$'
) )
parallel ./yapf -i -- "${files[@]}"
~/chromiumos/chromite/contrib/reflow_overlong_comments "${files[@]}"

The files that still had strings that were too long were manually
reformatted because they were easy and only a few issues.
autoninja.py
clang_format.py
download_from_google_storage.py
fix_encoding.py
gclient_utils.py
git_cache.py
git_common.py
git_map_branches.py
git_reparent_branch.py
gn.py
my_activity.py
owners_finder.py
presubmit_canned_checks.py
reclient_helper.py
reclientreport.py
roll_dep.py
rustfmt.py
siso.py
split_cl.py
subcommand.py
subprocess2.py
swift_format.py
upload_to_google_storage.py

These files still had lines (strings) that were too long, so the pylint
warnings were suppressed with a TODO.
auth.py
gclient.py
gclient_eval.py
gclient_paths.py
gclient_scm.py
gerrit_util.py
git_cl.py
presubmit_canned_checks.py
presubmit_support.py
scm.py

Change-Id: Ia6535c4f2c48d46b589ec1e791dde6c6b2ea858f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4836379
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Auto-Submit: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
2023-09-06 05:48:55 +00:00

67 lines
2.2 KiB
Python

#!/usr/bin/env python3
# Copyright (c) 2023 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""
Migrates an infra or infra_internal gclient to an infra_superproject one.
Does an in-place migration of the cwd's infra or infra_internal gclient
checkout to an infra_superproject checkout, preserving all repo branches
and commits. Should be called in the gclient root directory (the one that
contains the .gclient file).
By default creates a backup dir of the original gclient checkout in
`<dir>_backup`. If something goes wrong during the migration, this can
be used to restore your environment to its original state.
"""
import argparse
import subprocess
import os
import sys
import shutil
def main(argv):
source = os.getcwd()
parser = argparse.ArgumentParser(
description=__doc__.strip().splitlines()[0],
epilog=' '.join(__doc__.strip().splitlines()[1:]))
parser.add_argument('-n',
'--no-backup',
action='store_true',
help='NOT RECOMMENDED. Skips copying the current '
'checkout (which can take up to ~15 min) to '
'a backup before starting the migration.')
args = parser.parse_args(argv)
if not args.no_backup:
backup = source + '_backup'
print(f'Creating backup in {backup}')
print('May take up to ~15 minutes...')
shutil.copytree(source, backup, symlinks=True, dirs_exist_ok=True)
print('backup complete')
print(f'Deleting old {source}/.gclient file')
gclient_file = os.path.join(source, '.gclient')
with open(gclient_file, 'r') as file:
data = file.read()
internal = "infra_internal" in data
os.remove(gclient_file)
print('Migrating to infra/infra_superproject')
cmds = ['fetch', '--force']
if internal:
cmds.append('infra_internal')
print('including internal code in checkout')
else:
cmds.append('infra')
shell = sys.platform == 'win32'
fetch = subprocess.Popen(cmds, cwd=source, shell=shell)
fetch.wait()
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))