I wrote a little python program as a personal utility to help me with some refactoring. It’s similar to unix replace, except it supports regular expressions and operates on all files in a directory and (optionally) all subdirectories.
The problem is I’m not replacing in place. I’m opening files, passing the contents into memory, and then overwriting the file, like so:
file = open('path/to/file','r') in_string = file.read() file.close() # ... #Processing logic # ... file = open('path/to/file','w') file.write(out_string) file.close()
Besides the obvious performance/memory concerns, which are legitimate, but not so much a problem for my use, there’s another drawback to this method. SVN freaks out. I can do some copy and paste workarounds after the fact to fix the checksum error that svn throws on a commit, but it makes the utility pointless.
Is there a better way to do this? I’m guessing that if I were editing the file in place there wouldn’t be any sort of problem. How do I go about that?
I suspect the problem is that you are in fact editing wrong files. Subversion should never raise any errors about check sums when you are just modifying your tracked files — independently of how you are modifying them.
Maybe you are accidentally editing files in the
.svndirectory? In.svn/text-base, Subversion stores copies of your files using the same name plus the extension.svn-base, make sure that you are not editing those!