mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2025-12-14 20:22:05 +00:00
Okay, this update is kinda big. Summary: - Trimmed unused keys in Exodus telecomms - Adds script that will run mapmerge2 on Travis to check branch for unused keys or key overflow, etc. - Fixes matching indentation style in tag-matcher and converts it to use Python 3.6 - Converts mapmerge2 to be used by Python 3.4 and above. Instead of 3.6 - Removes Windows 1252 characters from Communication-blackout.dm that were not able to be seen in UTF-8 format. Note: the last commit will fail because currently main level is broken Example of no map issues:  Example of issues: 
51 lines
1.9 KiB
Python
51 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
import os
|
|
import pygit2
|
|
import dmm
|
|
from mapmerge import merge_map
|
|
|
|
def main(repo):
|
|
if repo.index.conflicts:
|
|
print("You need to resolve merge conflicts first.")
|
|
return 1
|
|
|
|
changed = 0
|
|
for path, status in repo.status().items():
|
|
if path.endswith(".dmm") and (status & (pygit2.GIT_STATUS_INDEX_MODIFIED | pygit2.GIT_STATUS_INDEX_NEW)):
|
|
# read the index
|
|
index_entry = repo.index[path]
|
|
index_map = dmm.DMM.from_bytes(repo[index_entry.id].read_raw())
|
|
|
|
try:
|
|
head_blob = repo[repo[repo.head.target].tree[path].id]
|
|
except KeyError:
|
|
# New map, no entry in HEAD
|
|
print("Converting new map: {}".format(path))
|
|
assert (status & pygit2.GIT_STATUS_INDEX_NEW)
|
|
merged_map = index_map
|
|
else:
|
|
# Entry in HEAD, merge the index over it
|
|
print("Merging map: {}".format(path))
|
|
assert not (status & pygit2.GIT_STATUS_INDEX_NEW)
|
|
head_map = dmm.DMM.from_bytes(head_blob.read_raw())
|
|
merged_map = merge_map(index_map, head_map)
|
|
|
|
# write to the index
|
|
blob_id = repo.create_blob(merged_map.to_bytes())
|
|
repo.index.add(pygit2.IndexEntry(path, blob_id, index_entry.mode))
|
|
changed += 1
|
|
|
|
# write to the working directory if that's clean
|
|
if status & (pygit2.GIT_STATUS_WT_DELETED | pygit2.GIT_STATUS_WT_MODIFIED):
|
|
print("Warning: {} has unindexed changes, not overwriting them".format(path))
|
|
else:
|
|
merged_map.to_file(os.path.join(repo.workdir, path))
|
|
|
|
if changed:
|
|
repo.index.write()
|
|
print("Merged {} maps.".format(changed))
|
|
return 0
|
|
|
|
if __name__ == '__main__':
|
|
exit(main(pygit2.Repository(pygit2.discover_repository(os.getcwd()))))
|