upconvert now creates .map extensions when appropriate.
This commit is contained in:
parent
f1d4449098
commit
eada46e2b5
1 changed files with 33 additions and 3 deletions
|
@ -28,7 +28,17 @@
|
|||
|
||||
import sys, os, re, getopt, curses.ascii, string, copy
|
||||
|
||||
vcdir = ".svn" # Change if we move away from Subversion
|
||||
## Version-control hooks begin here.
|
||||
#
|
||||
# Change these if we move away from Subversion
|
||||
|
||||
vcdir = ".svn"
|
||||
|
||||
def vcmove(src, dst):
|
||||
"Move a file under version control. Only applied to unmodified files."
|
||||
return "svn mv %s %s" % (src, dst)
|
||||
|
||||
## Version-control hooks end here
|
||||
|
||||
filemoves = {
|
||||
# Older includes all previous to 1.3.1.
|
||||
|
@ -494,7 +504,16 @@ def translator(filename, mapxforms, textxform):
|
|||
if not map_only:
|
||||
newdata.append("\"" + terminator)
|
||||
elif "map_data=" in line and (line.count("{") or line.count("}")):
|
||||
newdata.append(line + terminator)
|
||||
newline = line
|
||||
refre = re.compile(r"\{@?([^A-Z].*)\}").search(line)
|
||||
if refre:
|
||||
mapfile = refre.group(1)
|
||||
if not mapfile.endswith(".map") and modified_maps.get(mapfile)==False:
|
||||
newline = newline.replace(mapfile, mapfile + ".map")
|
||||
newdata.append(newline + terminator)
|
||||
if verbose > 0 and newline != line:
|
||||
print >>sys.stderr, 'upconvert: "%s", line %d: %s -> %s.' % (filename, lineno, line, newline)
|
||||
modified = True
|
||||
elif "map_data=" in line and line.count('"') > 1:
|
||||
print >>sys.stderr, 'upconvert: "%s", line %d: one-line map.' % (filename, lineno)
|
||||
newdata.append(line + terminator)
|
||||
|
@ -504,6 +523,10 @@ def translator(filename, mapxforms, textxform):
|
|||
newdata.append(newline + terminator)
|
||||
if newline != line:
|
||||
modified = True
|
||||
# Track which maps are modified, we'll use this later for determining
|
||||
# which files get a .map extension.
|
||||
if "maps" in filename:
|
||||
modified_maps[filename] = modified
|
||||
# Return None if the transformation functions made no changes.
|
||||
if modified:
|
||||
return "".join(newdata)
|
||||
|
@ -531,7 +554,7 @@ def allcfgfiles(dir):
|
|||
if interesting(os.path.join(root, name)):
|
||||
datafiles.append(os.path.join(root, name))
|
||||
datafiles.sort() # So diffs for same campaigns will cluster in reports
|
||||
return datafiles
|
||||
return map(os.path.normpath, datafiles)
|
||||
|
||||
def help():
|
||||
sys.stderr.write("""\
|
||||
|
@ -707,6 +730,7 @@ if __name__ == '__main__':
|
|||
|
||||
for dir in arguments:
|
||||
ofp = None
|
||||
modified_maps = {}
|
||||
if "older" in versions:
|
||||
lock_terrain_coding = None
|
||||
else:
|
||||
|
@ -748,5 +772,11 @@ if __name__ == '__main__':
|
|||
sys.stderr.write("upconvert: internal error on %s\n" % fn)
|
||||
(exc_type, exc_value, exc_traceback) = sys.exc_info()
|
||||
raise exc_type, exc_value, exc_traceback
|
||||
# Time for map file renames
|
||||
if not fn.endswith(".map") and modified_maps.get(fn) == False:
|
||||
mover = vcmove(fn, fn + ".map")
|
||||
print mover
|
||||
if not dryrun:
|
||||
os.system(mover)
|
||||
|
||||
# upconvert ends here
|
||||
|
|
Loading…
Add table
Reference in a new issue