简体   繁体   English

核心数据版本控制和SVN

[英]Core Data versioning and SVN

I use Xcode Repositories for working with svn, and today i added a new version to my Core Data Model and tried to commit it. 我使用Xcode Repositories来处理svn,今天我向核心数据模型添加了一个新版本,并尝试提交它。 But Xcode through an error: 但是Xcode通过一个错误:

svn: Commit failed (details follow):
svn: Entry for '/Users/user/Desktop/project/Core Data/Translator.xcdatamodeld/Translator 2.0.xcdatamodel/contents' is marked as 'copied' but is not itself scheduled
for addition.  Perhaps you're committing a target that is
inside an unversioned (or not-yet-versioned) directory?

I think that the problem is that svn treates xcdatamodel as a dolder, and since it is changed it doesn's under version control anymore. 我认为问题在于svn将xcdatamodel视为dolder,并且由于更改了它,因此不再受版本控制。 But what should i do then? 但是我该怎么办? Don't commit new models and transfer it manually?) 不提交新模型并手动进行转移?)

I would recommend writing a subversion checkout/commit hook that would create a zip or tar archive of the Translator.xcdatamodeld directory, and then check that in. The actual xcdatamodeld directory would be ignored. 我建议编写一个Subversion签出/提交钩子,该钩子将创建Translator.xcdatamodeld目录的zip或tar存档,然后将其检入。实际的xcdatamodeld目录将被忽略。 (It would probably be best not to compress the archive, since compressing will just make it harder for svn to compute diffs and make your repository larger.) (最好不要压缩档案,因为压缩只会使svn更加难于计算差异并使存储库更大。)

The problem is that when you start with the first data model, Xcode creates a file, let's say: myProject.xcdatamodeld 问题是,当您从第一个数据模型开始时,Xcode会创建一个文件,例如:myProject.xcdatamodeld

Let's say that you create, via menu Editor > Add Model Version , a second version of the model named _myProject_v2_. 假设您通过菜单编辑器>添加模型版本创建名为_myProject_v2_的模型的第二个版本。 What Xcode actually does is: it creates a folder, named as your original model, and copies the original model in a subfolder, then creates a second subfolder with a file containing the new version: Xcode的实际作用是:创建一个名为您的原始模型的文件夹,然后将原始模型复制到一个子文件夹中,然后使用包含新版本的文件创建另一个子文件夹:

myProject.xcdatamodeld
    |
    +- myProject.xcdatamodel
    |           |
    |           +- contents (a file containing the actual model)
    |
    +- myProject_v2.xcdatamodel
                |
                +- contents (a file containing the 2nd version of the model)

So SVN gets confused, because what he thinks is a file (the original myProject.xcdatamodeld) and which is stored in SVN, is now a folder, with subfolders. SVN感到困惑,因为他认为是一个文件(原始myProject.xcdatamodeld)并存储在SVN中,现在它是一个带有子文件夹的文件夹。 And moreover, these subfolders, being created by XCode, gets eventually their hidden .svn folder.. so my solution is: 而且,这些由XCode创建的子文件夹最终会获得其隐藏的.svn文件夹..因此,我的解决方案是:

  1. delete folder myProject.xcdatamodeld from SVN 从SVN删除文件夹myProject.xcdatamodeld
  2. do a commit of the rest 其余的承诺
  3. close Xcode and rename your folder project: eh: _projectFolder_old_ 关闭Xcode并重命名您的文件夹项目:eh:_projectFolder_old_
  4. do a checkout of the project, which hopefully will not have a myProject.xcdatamodeld 对项目进行检出,希望不会有myProject.xcdatamodeld
  5. from within xcode, create a bogus data model named myProject . 在xcode中,创建一个名为myProject的虚假数据模型。 Don't create anything in the model, it's useless 不要在模型中创建任何东西,这是没有用的
  6. version it, with Editor > Add Model Version 使用编辑器>添加模型版本对其进行版本控制
  7. close XCode 关闭XCode
  8. open in Finder your old datamodel in myProject.xcdatamodeld (right mouse button, Show package contents ) 在Finder中打开myProject.xcdatamodeld中的旧数据模型(鼠标右键, 显示包内容
  9. open in Finder your original model and copy the contents file from *projectFolder_old/myProject.xcdatamodeld/myProject.xcdatamodel* to the new project: projectFolder/myProject.xcdatamodeld/myProject.xcdatamodel (you will need to do a couple of Show Package Contents 在Finder中打开您的原始模型,然后将内容文件从* projectFolder_old / myProject.xcdatamodeld / myProject.xcdatamodel *复制到新项目: projectFolder / myProject.xcdatamodeld / myProject.xcdatamodel (您需要做几个Show Package Contents
  10. repeat for your second version, copy the contents file from *projectFolder_old/myProject.xcdatamodeld/myProject_v2.xcdatamodel* to the new project: *projectFolder/myProject.xcdatamodeld/myProject_v2.xcdatamodel* 重复第二个版本,将内容文件从* projectFolder_old / myProject.xcdatamodeld / myProject_v2.xcdatamodel *复制到新项目:* projectFolder / myProject.xcdatamodeld / myProject_v2.xcdatamodel *
  11. reopen Xcode and check everything is correct 重新打开Xcode并检查一切正确
  12. add to svn the files, if not already added, and do a commit 添加以svn文件(如果尚未添加),并进行提交

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM