tags:

views:

447

answers:

3

I'm using MySQL Workbench to maintain the database schema for an application. The .mwb file that Workbench uses, which is a zipped XML document, is kept in a Subversion repository.

The file is treated as binary data by Subversion, so I cannot use svn diff to show the changes, for example before committing.

Since the data is really XML, I'm thinking there might be some way to show the diff anyway, maybe some script that unzips the file before, or some plugin to svn diff.

The ideal solution would allow this:

$ svn diff db-model.mwb

or even using Meld:

$ meld db-model.mwb

What approach can you think of to accomplish this? Maybe someone else has had this problem of showing diff's for archived text files in Subversion.

+4  A: 

Subversion allows you to use external differencing tools . What you can do is write a wrapper script, and tell Subversion to use it as its "diff" command. Your wrapper would parse the arguments it gets from Subversion to pick out the "left" and "right" filenames, operate on them, and return an error code that Subversion will interpret as success or failure. In your case, the wrapper could unzip the XML files, and pass the unzipped results to "diff" or another tool of your choice.

Subversion will balk at diff-ing files that were detected as "binary" when they were checked in. The "--force" option lets you override this check, so your wrapper script will be be run even if the input files are checked in as binaries.

Jim Lewis
Thanks. Turns out this was kinda difficult. Subversion won't call any external differencing tools as long as the file has a svn:mime-type property set to something 'non human-readable' (like my zip files). But removing that property will cause the zip file to not be versioned as a binary file, which is not so good, right?
Oskar
I wouldn't remove the property -- SVN may need it for other reasons. Did you try the "--force" option to get SVN to run your diff wrapper script?
Jim Lewis
--force did the trick!
Oskar
A: 

I had been contemplating how to deal with MySQL Workbench files, but I was thinking about writing something so that before check in the files are unzipped and then on check out they are re-zipped. This may not work for high traffic sites, but I'm the primary person using my subversion repository so performance isn't nearly the issue. The idea where would be I could easily diff the files AND since they are stored as text I could easily manipulate them if the need ever arises.

Is there a reason they're better stored as zip files in the repository? I understand you may already have them in that way, I'm just asking in general is there a reason my idea is bad.

William Triest
No I don't see any good reason to store the files as zip in the repo and your idea sound pretty good to me. Please let me know how it works out for you!
Oskar
Actually the more I think about, the more annoying is it that Workbench uses a zipped file instead of a plain text project structure (like Visual Studio Database Edition, which is dead easy to keep in version control..)
Oskar
A: 

Actually, the problem is more general. OpenOffice uses zipped XML files for its content and so does MS Word and Excel since Version 2007. It is simple and effective to use XML as flexible Data Structure and Zip to save space. So I think subversion should be able to handle zipped XML. These XML data should be stored as Text, so the Repository would only grow with changes.

Does anyone know, whether there is a feature of subversion to handle this?

Joachim