cocoasvnpackagensdocumentnsfilewrapper

Recipe for making Cocoa NSDocument packages play well with svn?


I have a tool that writes package-style documents. It's implemented using NSDocument and overrides the following NSDocument methods:

- (NSFileWrapper *)fileWrapperOfType:(NSString *)typeName
                              error:(NSError **)outError;

- (BOOL)readFromFileWrapper:(NSFileWrapper *)fileWrapper
                    ofType:(NSString *)typeName
                     error:(NSError **)outError;

This is all lovely, except when I save a document that's under version control. (The .svn directories aren't preserved, etc.)

Is there a good recipe somewhere for making my documents play well with svn?


Solution

  • I'm guessing your code works by creating a fresh file wrapper each time -fileWrapperOfType:error: is called. This is convenient, but disregards any additional files that may exist on disk inside the package.

    So instead, what if you start by creating/using a file wrapper that refers to the existing contents on disk. Modify that wrapper to match the document's current state, and return the result. When that wrapper is written out to disk, svn files should be properly maintained.