backport: removal of files on Windows before --revert and conversion file rename
Windows won't allow a rename to overwrite an existing file (without Error 183, file already exists).
This commit is contained in:
parent
8b0bce5d15
commit
2fc24bf8aa
1 changed files with 4 additions and 0 deletions
|
@ -2098,6 +2098,8 @@ if __name__ == '__main__':
|
|||
elif revert:
|
||||
print "wmllint: reverting %s" % backup
|
||||
if not dryrun:
|
||||
if sys.platform == 'win32':
|
||||
os.remove(fn)
|
||||
os.rename(backup, fn)
|
||||
elif diffs:
|
||||
# Display diffs
|
||||
|
@ -2116,6 +2118,8 @@ if __name__ == '__main__':
|
|||
if changed:
|
||||
print "wmllint: converting", fn
|
||||
if not dryrun:
|
||||
if sys.platform == 'win32' and os.path.exists(backup):
|
||||
os.remove(backup)
|
||||
os.rename(fn, backup)
|
||||
ofp = open(fn, "w")
|
||||
ofp.write(changed)
|
||||
|
|
Loading…
Add table
Reference in a new issue