This commit implements described in the #104573. The goal is to fix the confusion of the submodule hashes change, which are not ideal for any of the supported git-module configuration (they are either always visible causing confusion, or silently staged and committed, also causing confusion). This commit replaces submodules with a checkout of addons and addons_contrib, covered by the .gitignore, and locale and developer tools are moved to the main repository. This also changes the paths: - /release/scripts are moved to the /scripts - /source/tools are moved to the /tools - /release/datafiles/locale is moved to /locale This is done to avoid conflicts when using bisect, and also allow buildbot to automatically "recover" wgen building older or newer branches/patches. Running `make update` will initialize the local checkout to the changed repository configuration. Another aspect of the change is that the make update will support Github style of remote organization (origin remote pointing to thy fork, upstream remote pointing to the upstream blender/blender.git). Pull Request #104755
64 lines
1.7 KiB
Python
64 lines
1.7 KiB
Python
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
from typing import (
|
|
Callable,
|
|
Generator,
|
|
Optional,
|
|
Sequence,
|
|
)
|
|
|
|
TextOpFn = Callable[
|
|
# file_name, data_src
|
|
[str, str],
|
|
# data_dst or None when no change is made.
|
|
Optional[str]
|
|
]
|
|
|
|
|
|
def operation_wrap(fn: str, text_operation: TextOpFn) -> None:
|
|
with open(fn, "r", encoding="utf-8") as f:
|
|
data_src = f.read()
|
|
data_dst = text_operation(fn, data_src)
|
|
|
|
if data_dst is None or (data_src == data_dst):
|
|
return
|
|
|
|
with open(fn, "w", encoding="utf-8") as f:
|
|
f.write(data_dst)
|
|
|
|
|
|
def run(
|
|
*,
|
|
directories: Sequence[str],
|
|
is_text: Callable[[str], bool],
|
|
text_operation: TextOpFn,
|
|
use_multiprocess: bool,
|
|
) -> None:
|
|
print(directories)
|
|
|
|
import os
|
|
|
|
def source_files(path: str) -> Generator[str, None, None]:
|
|
for dirpath, dirnames, filenames in os.walk(path):
|
|
dirnames[:] = [d for d in dirnames if not d.startswith(".")]
|
|
for filename in filenames:
|
|
if filename.startswith("."):
|
|
continue
|
|
filepath = os.path.join(dirpath, filename)
|
|
if is_text(filepath):
|
|
yield filepath
|
|
|
|
if use_multiprocess:
|
|
args = [
|
|
(fn, text_operation) for directory in directories
|
|
for fn in source_files(directory)
|
|
]
|
|
import multiprocessing
|
|
job_total = multiprocessing.cpu_count()
|
|
pool = multiprocessing.Pool(processes=job_total * 2)
|
|
pool.starmap(operation_wrap, args)
|
|
else:
|
|
for directory in directories:
|
|
for fn in source_files(directory):
|
|
operation_wrap(fn, text_operation)
|