Reputation: 109
We have been having issues where employees commit the SQL files *.SQL files accidently or by mistake as binary instead of text. Is there an easy way to change the format in Collabnet Subversion of files ending in *.SQL to text. The problem is that Subversion does not show the revisioncorrectly when it does a DIFF between the text file & binary. If we commit again as text then it is a text to text DIFF. Text to Binary DIFF shows this below when there are changes:
- No changes -
Diff Legend
– Removed lines
+ Added lines
< Changed lines
> Changed lines
Any easy way to convert or prevent the incorrect checkin? Any way subversion can check if file extension is *.sql and convert/prevent it as being commited as binary? Any way to identify all files ending *.SQL which are saved as binary instead of text in subversion? Can this be done within subversion or with Tortoise without any other tools?
Upvotes: 1
Views: 477
Reputation: 107080
Subversion doesn't really have Text vs Binary mode with files. All files are stored in the same format.
In Subversion, all a binary file means is that Subversion shouldn't try to merge this file, or do a text diff on it.
Subversion determines whether or not a file is a text file by setting a file property called svn:mime-type
. If this isn't set, the file is a text file. If it is set, the file is assumed to be binary. (It might still be considered a text file if the mime-type starts with text/
, but I'm not 100% sure...)
What you need to do is to configure your mime-type file to understand that *.sql
files are text files. If you use Apache httpd for your Subversion server, you can edit the mime-types
file that usually sits in the conf
directory where httpd.conf
is located.
You can also set this on a per-user basis by setting your $HOME/.subversion/config
file in Unix, or by editing your Subversion Registry Entries on Windows.
What you do is setup a mime types file, and then point the mime-types-file
entry to that file.
The MIME types file is simply a two column affair with the MIME type in the first column and the suffix in the second column. You need to add something like this:
text/sql sql
This will guarantee that any file that ends in *.sql
is a text file.
For the files you've entered, just remove the property on them:
$ svn propdel svn:mime-type *.sql
$ svn commit -m"Making my SQL files text files"
Upvotes: 3