views:

222

answers:

1

Subversion sets a binary file's svn:mime-type property to application/octet-stream by default.

I need to change this default to some other mime-type. When I import for the first time this code, I would like Subversion to set mime-type to the one I choose.

The reason is that my code base contains code in binary files (proprietary format), and I have the applications necessary to emulate diff and diff3 for these. But Subversion does not let me due to their default mime-type.

Please note: There is no default extension (*.jar, *.py, etc) for these code files. Some files don't even have an extension. So configuring mime-type by file extension is not possible.

+2  A: 

--- Edited after response that there is no default extension for these files ---

If there is no default extension for these files, you can sill use the [auto-props] directive in the client, under a few circumstances.

If the file has a known reserved file name (like Makefile), then you can put in a directive that matches the entire file name, like

Makefile = svn:mime-type=text/x-makefile

Should you only have a few file names to cover, you could just add in the directives for the each of the desired file names.

The * is not just limited to extension matching, the directives match file name patters, so you could also write a directive like

Image* = svn:mime-type=image/png

Finally, if your files do not follow a naming pattern which can be explicitly reserved for your mime type, then you'll just be better off writing a small script to tag the files and remembering to run it occasionally.

Note that changing the client defaults will change the client behavior for access to all SVN repositories, so it's a good idea to only put in sane choices which probably would apply to every repository you intend to use.

--- Original post follows ---

The svn:mime-type is a property. For existing entries, you can edit it with svn propedit

To change the mime-type's default, on the client side, you can edit the svn config file to include a directive in the [auto-props] section of the config file.

*.png = svn:mime-type=image/png

would automatically add a svn:mime-type of image/png to any new file created that ended in *.png

I'm not aware of any technique where this can be done server side, unless you want to write up a script in one of the pre-commit triggers to add the property before the change is committed to the repository.

Edwin Buck
There is no default extension for this code. Some files don't even have an extension. So configuring mime-type by file extension is not possible. I need to change the default mime-type for binary files to something else.
lamcro