views:

905

answers:

7

I'm working on an Open Office document with a partner and we are using subversion to collaborate on it. However, we are saving the document as a .odt file and subversion reads this as a binary file type. Therefore it has me worrying that when we go to merge the files and the diff pops up that we will not be able to adequately perform the merges if there are conflicts; we won't be able to understand the raw .odt file.

So my question is "How do I save a document in Open Office so that it retains all of the formatting you would expect and want but does save as a binary file and therefore can be easily merged?"

Or am I using the wrong method to do this? (Which is more than likely)

+7  A: 

For complex binary file formats (of which .odt is one), I have found that it is a good idea to use locking in Subversion and not try to merge changes. Set the Subversion property svn:needs-lock on the file and you will then be required to request a lock on the file before you edit it (see Locking in the Subversion book for more details). This has worked well in my situation but it depends on your level of collaboration whether it will work well for you.

Greg Hewgill
A good answer, so +1, but I've already done that and the thing I really want is a way to have a file that is man-readable at the raw level while still playing host to the formatting provided in .odt files. (I'll mark someone with the answer if there is no way to do what I want)
Robert Massaioli
+4  A: 

The .odt files are AFAIK zipped XML files. However even if you would save them as unzipped XML I seriously doubt that you could do merges of anything but the smallest changes.

lothar
I'll look into it but I bet you're right. It would be unlikely that I could spot the changes; still atleast I know what I'm doing now. Thanks for the (AFAIK info +1)
Robert Massaioli
+1  A: 

The .odt format is actually a zip file format (in most cases), which packages up your document and possibly other binary resources. The fact that it's a zip file, means it's inherently binary. There may be a way to save the document in plain-text XML using OpenOffice I'm not sure.

If you really need the ability to merge changes, you'll probably be better off with a plain text format.

Andy White
+10  A: 

As much as you might hate it, LaTeX provides you a means to create documents, but maintain them in subversion as text, which is easily merged.

Aside from LaTeX or just keeping txt documents, setting a Lock on the file with Subversion is your best bet.

geowa4
And once you start using LaTeX you don't hate it so much any more...
David Zaslavsky
Considering Latex now ... +1
Robert Massaioli
Actually svn was the reason why I started to use LaTeX again... And you can add small scripts that add "svn info" right into the LaTeX document so you know what version you are using.
Johan
That svn info stuff sounds really handy.
Robert Massaioli
A jump to LaTeX is a bit too radical for many businesses unfortunately.
Craig McQueen
+1  A: 

Merging a complex page will be a problem, as subversion won't be able to do a good job.

By locking, only one person can work on it at a time.

You could save it as an html page each time, if you don't like the LaTex or .txt suggestions.

You could write some plugin for OpenOffice that will allow collaborative work, perhaps.

James Black
+5  A: 

A file doesn't have to be a text format to be diffed and merged—as long as the vendor provides a good diff and merge tool. And as long as the VCS can be configured to use these external diff/merge tools. However it's rare to have such diff and merge tools provided for proprietary doc formats.

TortoiseSVN can diff Word docs and that's extremely handy. It can apparently merge too, although I've never tried that. I think it may be able to diff and merge OpenOffice docs, but I've never tried it.

TortoiseSVN can "sort of" diff Excel docs, but it's not very nice to use. No merging.

At my company, we set svn:needs-lock on Word and Excel docs to avoid merge troubles. Even then I find it very handy to be able to diff previous revisions and see what changed.

Craig McQueen
I did not know that TortoiseSVN could do that. +1
Robert Massaioli
A: 

Complex machine-maintained files will always be hard to merge in a version control system, even if they're stored as text. What if it were uncompressed OpenOffice.org XML? A simple change you make will modify lots of lines throughout the XML file, resulting in possible conflicts.

Your best bet would be to use a simpler format, such Markdown, because a simple format leads to less changes, which leads to more reliable merging. Many writers use Markdown and it's easy to learn.

There are tons of editors that support this markup language, but you may have to modify your workflow a bit. There is for example a ODT to txt conversion script, that converts ODF to txt with markdown formatting. Also, pandoc can convert between many formats, such as Markdown and ODF.

So there are two options:

  1. Change to an editor that directly supports Markdown (a simple text editor will do, but you could go for a more advanced text editor with Markdown mode such as VIM Markdown mode)
  2. Insert a conversion step between Markdown and OpenOffice.org format. (make sure to test the viability first)
Martijn Heemels