Processing invalid patches
I just got a patch file that SVN couldn't handle. I handled the issue with this piece of code, here for future reference:
import System.IO
file = """random.patch""";
lines = File.ReadAllLines(file)
currentFile as TextWriter
for line in lines:
if line.StartsWith("+++"):#new file
currentFile.Dispose() if currentFile is not null
fileName = line.Replace("+++","").Replace("(revision 0)","").Trim()
currentFile = File.CreateText(fileName)
print fileName
continue
continue if not line.StartsWith("+")
currentFile.WriteLine( line.Substring(1) )
I love Boo!
Comments
Can't you say
"continue unless line.StartsWith("+")" ?
Yes, as a matter of fact I can, just didn't think of it.
Comment preview