Skip to content

Commit

Permalink
Merge pull request #61 from bewebste/master
Browse files Browse the repository at this point in the history
[NEW] Brian Webster's contributed template to help diff .xcdatamodels.
  • Loading branch information
rentzsch committed Jun 4, 2011
2 parents af31df9 + 399b125 commit 2d0e0d9
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
23 changes: 23 additions & 0 deletions contributed templates/Brian Webster/Diff template readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Diff mogenerator template
-------------------------
This template was created for the use case of merging two versions of a .xcdatamodel file,
e.g. when doing a merge in a version control system. Since data model files are stored as
binary data, there is no way to directly diff them. Additionally, since it's an undocumented
format, even if we're able to diff them, there still isn't any way to automatically apply those diffs.

The template itself basically just dumps the relevant properties and relationships for each
entity in the data model into a pseudo plist looking format, with each relevant attribute put
on its own line. In order to merge two versions of a data model, you would perform the following
steps:

1. Run mogenerator on each of the two versions of the data model and put the results into two
different directories.
2. Use your favorite diff tool to diff the two resulting directories
3. Look at the changes in each class, then use the data model editor in Xcode to manually apply
each change to one of the two versions of the data model, so that they match
4. Once you've gone through and made all the changes, you can re-run mogenerator on the edited
version, re-diff them, and double check that you didn't miss anything

The one major caveat here is that only entites in the data model are currently handled, so if
your model has any fetch request templates in it, those will not be included in the output.
If anyone wants to add them to the output, feel free. :)
39 changes: 39 additions & 0 deletions contributed templates/Brian Webster/machine.h.motemplate
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
name = <$name$>,
managedObjectClassName = <$managedObjectClassName$>,
renamingIdentifier = <$renamingIdentifier$>,
isAbstract = <$isAbstract$>,
userInfo = <$userInfo$>,
relationships = (
<$foreach Relationship noninheritedRelationships do$>
{
name = <$Relationship.name$>,
isIndexed = <$Relationship.isIndexed$>,
isTransient = <$Relationship.isTransient$>,
isOptional = <$Relationship.isOptional$>,
userInfo = <$Relationship.userInfo$>,
destinationEntity = <$Relationship.destinationEntity.name$>,
inverseRelationship = <$Relationship.inverseRelationship.name$>,
deleteRule = <$Relationship.deleteRule$>,
maxCount = <$Relationship.maxCount$>,
minCount = <$Relationship.minCount$>,
isToMany = <$Relationship.isToMany$>
}
<$endforeach do$>
)
attributes = (
<$foreach Attribute noninheritedAttributes do$>
{
name = <$Attribute.name$>,
isIndexed = <$Attribute.isIndexed$>,
isTransient = <$Attribute.isTransient$>,
isOptional = <$Attribute.isOptional$>,
userInfo = <$Attribute.userInfo$>,
attributeType = <$Attribute.attributeType$>,
attributeValueClassName = <$Attribute.attributeValueClassName$>,
defaultValue = <$Attribute.defaultValue$>,
valueTransformerName = <$Attribute.valueTransformerName$>
}
<$end>
)
}

0 comments on commit 2d0e0d9

Please sign in to comment.