Browse Source

Make the scripts describe how to generate patches that are identical to ones created previously with manual commands.

master
poikilos 3 years ago
parent
commit
5c3b02f714
  1. 10
      basecompare.py
  2. 87
      headcompare.py

10
basecompare.py

@ -9,7 +9,7 @@ from headcompare import (
defaultVirtualReposDir, defaultVirtualReposDir,
minetestPath, minetestPath,
gamesPath, gamesPath,
gamePath, defaultGamePath,
profile, profile,
) )
@ -34,8 +34,8 @@ def usage():
error("") error("")
def main(): def main():
global gamePath global defaultGamePath
gamePath = None defaultGamePath = None
if len(sys.argv) < 2: if len(sys.argv) < 2:
usage() usage()
error("Error: You must provide a branch name.\n") error("Error: You must provide a branch name.\n")
@ -46,9 +46,9 @@ def main():
"".format(sys.argv)) "".format(sys.argv))
exit(1) exit(1)
if len(sys.argv) > 2: if len(sys.argv) > 2:
gamePath = sys.argv[2] defaultGamePath = sys.argv[2]
results = compareBranch(sys.argv[1], gamePath=gamePath, results = compareBranch(sys.argv[1], gamePath=defaultGamePath,
compareOld=True) compareOld=True)
error("# ^ Do that to verify: they MUST match, and the first" error("# ^ Do that to verify: they MUST match, and the first"
" directory must be unmodified from the original" " directory must be unmodified from the original"

87
headcompare.py

@ -5,7 +5,7 @@ import os
import platform import platform
me = os.path.basename(__file__) me = os.path.basename(__file__)
myDir = os.path.dirname(__file__) myDir = os.path.dirname(os.path.abspath(__file__))
defaultVirtualReposDir = myDir defaultVirtualReposDir = myDir
def error(msg): def error(msg):
@ -46,7 +46,7 @@ else:
minetestPath = os.path.join(profile, "minetest") minetestPath = os.path.join(profile, "minetest")
gamesPath = os.path.join(minetestPath, "games") gamesPath = os.path.join(minetestPath, "games")
gamePath = None defaultGamePath = None
def compareBranch(branchName, gamePath=None, bgVersion=None, def compareBranch(branchName, gamePath=None, bgVersion=None,
@ -83,6 +83,11 @@ def compareBranch(branchName, gamePath=None, bgVersion=None,
versionMsg = "specified" versionMsg = "specified"
if (len(parts) > 2) and (parts[-2] == "vs"): if (len(parts) > 2) and (parts[-2] == "vs"):
detectedBGVer = parts[-1] detectedBGVer = parts[-1]
if os.path.sep in branchName:
branchName = os.path.split(branchName)[1]
myDirSlash = myDir + os.path.sep
if bgVersion is not None: if bgVersion is not None:
if detectedBGVer is not None: if detectedBGVer is not None:
print("WARNING: detected version {} but you specified {}" print("WARNING: detected version {} but you specified {}"
@ -90,24 +95,19 @@ def compareBranch(branchName, gamePath=None, bgVersion=None,
else: else:
bgVersion = detectedBGVer bgVersion = detectedBGVer
versionMsg = "detected" versionMsg = "detected"
''' if compareOld:
tryGame = "bucket_game"
tryGamePath = os.path.join(gamesPath, tryGame)
if not os.path.isdir(tryGamePath):
tryGame = "Bucket_Game"
tryGamePath = os.path.join(gamesPath, tryGame)
'''
if bgVersion is None: if bgVersion is None:
raise ValueError("The game version was neither specified nor " raise ValueError("The game version was neither specified "
" after \"-vs-\" in the patch name.") " nor after \"-vs-\" in the patch name.")
specifiedGame = "bucket_game-{}".format(bgVersion) detectedGame = "bucket_game-{}".format(bgVersion)
# os.path.join(bgVersionsPath, specifiedGame) # os.path.join(bgVersionsPath, detected)
specifiedGamePath = os.path.join(bgVersionsPath, specifiedGame) detectedPath = os.path.join(bgVersionsPath, detected)
if not os.path.isdir(specifiedGamePath): if not os.path.isdir(detectedPath):
usage() usage()
raise ValueError("The {} game version is not present at" raise ValueError("The {} game version is not present at"
" {}".format(versionMsg, specifiedGamePath)) " {}".format(versionMsg, detectedPath))
if branchesPath is None: if branchesPath is None:
if compareOld: if compareOld:
branchesPath = os.path.join(vReposDir, branchesPath = os.path.join(vReposDir,
@ -115,27 +115,60 @@ def compareBranch(branchName, gamePath=None, bgVersion=None,
else: else:
branchesPath = os.path.join(vReposDir, branchesPath = os.path.join(vReposDir,
"Bucket_Game-branches") "Bucket_Game-branches")
if os.path.sep in branchName: if gamePath is None:
branchName = os.path.split(branchName)[1] if compareOld:
gamePath = detectedPath
basePath = detectedPath
else:
tryGame = "bucket_game"
tryGamePath = os.path.join(gamesPath, tryGame)
if not os.path.isdir(tryGamePath):
tryGame = "Bucket_Game"
tryGamePath = os.path.join(gamesPath, tryGame)
gamePath = tryGamePath
basePath = os.path.join(vReposDir, "Bucket_Game-base",
branchName)
basePath = os.path.realpath(basePath)
if not os.path.isdir(gamePath):
usage()
raise ValueError("The {} game version is not present at"
" {}".format(versionMsg, gamePath))
branchPath = os.path.join(branchesPath, branchName) branchPath = os.path.join(branchesPath, branchName)
if not os.path.isdir(branchPath): if not os.path.isdir(branchPath):
raise ValueError("The branch wasn't found at \"{}\"" raise ValueError("The branch wasn't found at \"{}\""
"".format(branchPath)) "".format(branchPath))
branchPath = os.path.realpath(branchPath) branchPath = os.path.realpath(branchPath)
print("meld \"{}\" \"{}\"".format(specifiedGamePath, branchPath))
basePathRel = basePath
if basePathRel.startswith(myDirSlash):
basePathRel = basePathRel[len(myDirSlash):]
gamePathRel = gamePath
if gamePathRel.startswith(myDirSlash):
gamePathRel = gamePathRel[len(myDirSlash):]
branchPathRel = branchPath
if branchPathRel.startswith(myDirSlash):
branchPathRel = branchPathRel[len(myDirSlash):]
print("meld \"{}\" \"{}\"".format(gamePath, branchPath))
patchFilePath = branchPath+".patch" patchFilePath = branchPath+".patch"
print("diff -ru \"{}\" \"{}\" > \"{}\"" print("diff -ru \"{}\" \"{}\" > \"{}\""
"".format(specifiedGamePath, branchPath, patchFilePath)) "".format(basePathRel, branchPathRel, patchFilePath))
results = { results = {
'gamePath': specifiedGamePath, 'gamePath': gamePath,
'branchPath': specifiedGamePath, 'branchPath': branchPath,
'patchFilePath': specifiedGamePath, 'patchFilePath': patchFilePath,
} }
return results return results
def main(): def main():
global gamePath global defaultGamePath
gamePath = None defaultGamePath = None
if len(sys.argv) < 2: if len(sys.argv) < 2:
usage() usage()
error("Error: You must provide a branch name.\n") error("Error: You must provide a branch name.\n")
@ -146,9 +179,9 @@ def main():
"".format(sys.argv)) "".format(sys.argv))
exit(1) exit(1)
if len(sys.argv) > 2: if len(sys.argv) > 2:
gamePath = sys.argv[2] defaultGamePath = sys.argv[2]
results = compareBranch(sys.argv[1], gamePath=gamePath) results = compareBranch(sys.argv[1], gamePath=defaultGamePath)
error("# ^ Do that to see the difference or generate a patch," error("# ^ Do that to see the difference or generate a patch,"
" but the first directory must be unmodified from the" " but the first directory must be unmodified from the"
" original release package.") " original release package.")

Loading…
Cancel
Save