added entries

This commit is contained in:
Trilarion
2018-07-02 13:08:51 +02:00
parent 90ae73ced7
commit 86daf99df7
13 changed files with 301 additions and 29 deletions

View File

@ -269,6 +269,7 @@
"https://github.com/snauts/game-lv.git",
"https://github.com/solarus-games/solarus.git",
"https://github.com/spring/spring.git",
"https://github.com/subchannel13/Stareater.git",
"https://github.com/superpowers/superpowers-core.git",
"https://github.com/supertuxkart/stk-code.git",
"https://github.com/suprafun/aiwars.git",
@ -287,6 +288,7 @@
"https://github.com/unknown-horizons/unknown-horizons.git",
"https://github.com/unnethack/unnethack.git",
"https://github.com/urho3d/Urho3D.git",
"https://github.com/valeriansaliou/boulder-dash.git",
"https://github.com/vcmi/vcmi.git",
"https://github.com/vcosta/derclou.git",
"https://github.com/vegastrike/Vega-Strike-Engine-Source.git",

View File

@ -0,0 +1,192 @@
"""
The svn is too big to be automatically imported to git (and Github) because there are lots of large binary data components.
Needs a manual solution.
"""
import json
from utils.utils import *
def special_treatment(destination, revision):
"""
"""
if revision == 5:
shutil.rmtree(os.path.join(destination, 'Holyspirit'))
def delete_global_excludes(folder):
"""
"""
for dirpath, dirnames, filenames in os.walk(folder):
rel_path = os.path.relpath(dirpath, folder)
if rel_path.startswith('.svn'):
continue
for file in filenames:
if file in global_exclude:
os.remove(os.path.join(dirpath, file))
def delete_empty_directories(folder):
"""
"""
for dirpath, dirnames, filenames in os.walk(folder, topdown=False):
rel_path = os.path.relpath(dirpath, folder)
if rel_path.startswith('.svn'):
continue
if not filenames and not dirnames:
os.removedirs(dirpath)
def list_large_unwanted_files(folder):
"""
"""
output = []
for dirpath, dirnames, filenames in os.walk(folder):
rel_path = os.path.relpath(dirpath, folder)
if rel_path.startswith('.svn'):
continue
for file in filenames:
file_path = os.path.join(dirpath, file)
already_listed = False
for extension in unwanted_file_extensions:
if file.endswith(extension):
output.append(os.path.join(rel_path, file))
already_listed = True
break
if not already_listed and os.path.getsize(file_path) > large_file_limit:
output.append(os.path.join(rel_path, file))
return output
def checkout(revision_start, revision_end):
"""
"""
assert revision_end >= revision_start
for revision in range(revision_start, revision_end + 1):
print('checking out revision {}'.format(revision))
# create destination directory
destination = os.path.join(svn_checkout_path, 'r{:04d}'.format(revision))
if os.path.exists(destination):
shutil.rmtree(destination)
# checkout
start_time = time.time()
subprocess_run(['svn', 'checkout', '-r{}'.format(revision), svn_url, destination])
print('checkout took {}s'.format(time.time() - start_time))
# sanitation (delete files from global exclude list)
delete_global_excludes(destination)
# list unwanted files
unwanted_files = list_large_unwanted_files(destination)
if unwanted_files:
text = json.dumps(unwanted_files, indent=1)
write_text(os.path.join(svn_checkout_path, 'r{:04d}_unwanted_files.json'.format(revision)), text)
# delete empty directories
delete_empty_directories(destination)
# special treatment
special_treatment(destination, revision)
def initialize_git():
"""
"""
# git init
os.mkdir(git_path)
os.chdir(git_path)
subprocess_run(['git', 'init'])
subprocess_run(['git', 'config', 'user.name', 'Trilarion'])
subprocess_run(['git', 'config', 'user.email', 'Trilarion@users.noreply.gitlab.com'])
def combine_log_messages(msg):
"""
"""
# throw out all empty ones
msg = [x.strip() for x in msg if x]
# combine again
msg = "\r\n".join(msg)
return msg
def read_logs():
"""
Probably regular expressions would have worked too.
"""
# read log
print('read all log messages')
os.chdir(svn_checkout_path)
start_time = time.time()
log = subprocess_run(['svn', 'log', svn_url], display=False)
print('read log took {}s'.format(time.time() - start_time))
# process log
log = log.split('\r\n------------------------------------------------------------------------\r\n')
# not the last one
log = log[:-2]
print('{} log entries'.format(len(log)))
# process log entries
log = [x.split('\r\n') for x in log]
# the first one still contains an additional "---" elements
log[0] = log[0][1:]
# split the first line
info = [x[0].split('|') for x in log]
# get the revision
revision = [int(x[0][1:]) for x in info]
author = [x[1].strip() for x in info]
unique_authors = list(set(author))
unique_authors.sort()
date = [x[2].strip() for x in info]
msg = [combine_log_messages(x[2:]) for x in log]
logs = list(zip(revision, author, date, msg))
logs.sort(key=lambda x: x[0])
return logs, unique_authors
if __name__ == "__main__":
global_exclude = ['Thumbs.db']
unwanted_file_extensions = ['.exe', '.dll']
large_file_limit = 1e6 # in bytes
# base path is the directory containing this file
base_path = os.path.abspath(os.path.dirname(__file__))
print('base path={}'.format(base_path))
# derived paths
svn_checkout_path = os.path.join(base_path, 'svn_checkout')
if not os.path.exists(svn_checkout_path):
os.mkdir(svn_checkout_path)
git_path = os.path.join(base_path, 'lechemindeladam')
# if not os.path.exists(git_path):
# initialize_git()
# svn url
svn_url = "https://svn.code.sf.net/p/lechemindeladam/code/"
# read logs
# logs, authors = read_logs()
# text = json.dumps(logs, indent=1)
# write_text(os.path.join(svn_checkout_path, 'logs.json'), text)
# text = json.dumps(authors, indent=1)
# write_text(os.path.join(svn_checkout_path, 'authors.json'), text)
checkout(1, 50)

View File

@ -146,7 +146,7 @@ def determine_latest_last_modified_date(folder):
return latest_last_modified
def subprocess_run(cmd):
def subprocess_run(cmd, display=True):
"""
Runs a cmd via subprocess and displays the std output in case of success or the std error output in case of failure
where it also stops execution.
@ -154,10 +154,11 @@ def subprocess_run(cmd):
result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if result.returncode:
print("error {} in call {}".format(result.returncode, cmd))
print(result.stderr.decode('ascii'))
print(result.stderr.decode('cp1252'))
sys.exit(-1)
else:
print(' output: {}'.format(result.stdout.decode('ascii')))
if display:
print(' output: {}'.format(result.stdout.decode('cp1252')))
return result.stdout.decode('cp1252')
def copy_tree(source, destination):