CVS is extremely popular for configuration management (with Subversion quickly gaining speed). It uses "optimistic locking" in which multiple users can work on the same file at the same time, and any conflicts are resolved when the file is "checked-in". This works wonderfully for text files in which multiple user’s changes can be merged together. This doesn’t work well for binary files. However, for best configuration management, plans, designs, and other artifacts should be placed under version control with the code they affect. So in our projects, the question always arises: How do you resolve CVS commit conflicts for binary files (specifically Word documents)?
So let’s say you’re using TortoiseCVS and decide to work on a file named "ProjectPlan.doc". Dutifully, you do a CVS update to get the latest version, make changes in Word, do a CVS commit and encounter:
cvs server: Up-to-date check failed for `Documentation/Plans/ProjectPlan.doc’
cvs [server aborted]: correct above errors first!
TortoiseCVS is nice and gives us the additional message:
Tortoise Tip: Someone else has committed a new version of one or more of the files you are trying to commit. You need to do a CVS Update and then try to commit again.
So what do you do? A CVS Update won’t work because CVS can’t merge the binary Word document changes. (If you try a CVS update, it will rename your existing modified file to something funny ("#ProjectPlan.doc.1.1" in my case), get the latest copy of the CVS version, and display a warning.) But Word can do the merge for you! So if you have a conflict with a Word document, do the following:
- Rename your modified local copy
- In my case, I renamed "ProjectPlan.doc" to "ProjectPlan-mod.doc"
- By renaming the file, we don’t have a "ProjectPlan.doc" file in the directory anymore (this is good since it prepares us for the next step).
- Do a CVS Update to get the latest CVS copy
- This will place the latest version in "ProjectPlan.doc"
- Open the latest CVS copy ("ProjectPlan.doc") in Word
- In Word, select Tools/Merge Documents, select your modified copy ("ProjectPlan-mod.doc"), and click "Open"
- At TCG we routinely leave "Track Changes" on in our checked in documents to facilitate easy comparison. If both documents had their changes tracked, the changes will merge nicely (though you will get a warning).
- Review your changes to make sure they were what you wanted
- Save your newly merged copy ("ProjectPlan.doc")
- Do a CVS Commit on your newly merged copy ("ProjectPlan.doc")
- Delete your unneeded modified version ("ProjectPlan-mod.doc")
Congratulations!