Files
test/tools/git/git_sh1_to_svn_rev.py
Campbell Barton e955c94ed3 License Headers: Set copyright to "Blender Authors", add AUTHORS
Listing the "Blender Foundation" as copyright holder implied the Blender
Foundation holds copyright to files which may include work from many
developers.

While keeping copyright on headers makes sense for isolated libraries,
Blender's own code may be refactored or moved between files in a way
that makes the per file copyright holders less meaningful.

Copyright references to the "Blender Foundation" have been replaced with
"Blender Authors", with the exception of `./extern/` since these this
contains libraries which are more isolated, any changed to license
headers there can be handled on a case-by-case basis.

Some directories in `./intern/` have also been excluded:

- `./intern/cycles/` it's own `AUTHORS` file is planned.
- `./intern/opensubdiv/`.

An "AUTHORS" file has been added, using the chromium projects authors
file as a template.

Design task: #110784

Ref !110783.
2023-08-16 00:20:26 +10:00

56 lines
1.5 KiB
Python
Executable File

#!/usr/bin/env python3
# SPDX-FileCopyrightText: 2023 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
# generate svn rev-sha1 mapping
import os
CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))
SOURCE_DIR = os.path.normpath(os.path.abspath(os.path.normpath(os.path.join(CURRENT_DIR, "..", ".."))))
print("creating git-log of %r" % SOURCE_DIR)
os.chdir(SOURCE_DIR)
os.system('git log --all --format="%H %cd" --date=iso > "' + CURRENT_DIR + '/git_log.txt"')
print("creating mapping...")
os.chdir(CURRENT_DIR)
time_to_sha1 = {}
f = "git_log.txt"
with open(f, "r", encoding="utf-8") as fh:
for l in fh:
sha1 = l[:40]
time = l[41:60]
time_to_sha1[time] = sha1
os.remove("git_log.txt")
# for reverse mapping
rev_sha1_ls = []
with open("rev_to_sha1.py", "w", encoding="utf-8") as fh_dst:
fh_dst.write("data = {\n")
f = "git_sh1_to_svn_rev.fossils"
with open(f, "r", encoding="utf-8") as fh:
for l in fh:
# skip 'SVN:'
rev, time = l[4:].split("\t", 1)
time = time.split("Z", 1)[0].replace("T", " ", 1)
sha1 = time_to_sha1.get(time)
if sha1 is not None:
fh_dst.write('%s: "%s",\n' % (rev, sha1))
rev_sha1_ls.append((rev, sha1))
fh_dst.write('}\n')
print("written: rev_to_sha1.py")
with open("sha1_to_rev.py", "w", encoding="utf-8") as fh_dst:
fh_dst.write("data = {\n")
for rev, sha1 in rev_sha1_ls:
fh_dst.write('"%s": %s,\n' % (sha1, rev))
fh_dst.write('}\n')
print("written: sha1_to_rev.py")