简体   繁体   English

如何撤消 SVN 上的更新

[英]How to undo an Update on SVN

I'm using SVN with Xcode.我正在使用 SVN 和 Xcode。 After implementing a certain functionality in my working copy, I was ready to commit my code to the repository.在我的工作副本中实现了某些功能后,我准备将我的代码提交到存储库。 However the server copy had been modified since my last checkout.但是,自从我上次结帐以来,服务器副本已被修改。 So I thought the best thing to do would be to update my project first, resolve conflicts if any, and then finally commit the code.所以我认为最好的办法是先更新我的项目,解决冲突(如果有),然后最后提交代码。 I did just that.我就是这么做的。 But now I find that there are a bunch of errors in my Project.但是现在我发现我的项目中有一堆错误。 These errors are mostly in the section of code that my co-worker had been working on.这些错误主要出现在我的同事一直在处理的代码部分中。 So I'm hesitant to modify his code to resolve the errors.所以我很犹豫修改他的代码来解决错误。 Is there a way I can undo the update?有没有办法可以撤消更新? As my code was working perfectly fine before the update, I'd like to continue working on it and maybe merge and commit my changes at a later stage.由于我的代码在更新之前运行良好,因此我想继续处理它,并可能在稍后阶段合并并提交我的更改。 Is there way I can do this?我有办法做到这一点吗?

XCode allows you to update code to a specific revision. XCode 允许您将代码更新到特定版本。 I'm not sure how to do this in XCode 4, but in XCode 3.2 you right click on a class file and click "Get Info".我不确定如何在 XCode 4 中执行此操作,但在 XCode 3.2 中,您右键单击 class 文件并单击“获取信息”。 In the info window, go to the "SCM" tab.在“SCM”选项卡的信息 window、go 中。 Over there you'll see a list of all the SVN revisions for that class file.在那里,您将看到该 class 文件的所有 SVN 修订的列表。 You should see your coworker's revision there, accompanied by his check in comment.您应该在那里看到您同事的修订,并附有他的签入评论。 Select the revision JUST BEFORE that one (this is the one you were working on before you did an update). Select 之前的版本(这是您在进行更新之前正在处理的版本)。 XCode will now allow you to update to that revision (Via an update button at the bottom of the info window). XCode 现在允许您更新到该版本(通过信息窗口底部的更新按钮)。

Do these steps for all class files affected by the erroneous update and you should be good to go!对受错误更新影响的所有 class 文件执行这些步骤,您应该一切顺利!

Also, you should probably inform your coworker to not check in erroneous code as a best practice:)此外,您可能应该通知您的同事不要签入错误代码作为最佳实践:)

This is what you should be looking at:这是您应该查看的内容:

在此处输入图像描述

EDIT:编辑:

For XCode4, I did some research and if what I found out so far is true, I'm SEVERELY disappointed with SCM functionality in XCode4 (refer: Where is the 'Revert' option in Xcode 4's Source Control? )对于 XCode4,我做了一些研究,如果到目前为止发现的结果属实,我对 XCode4 中的 SCM 功能感到非常失望(请参阅: Xcode 4 的源代码控制中的“还原”选项在哪里?

So I have determined that the functionality to update to a specific revision has been pulled out of Xcode4 (If I am wrong I stand open to correction).所以我已经确定更新到特定版本的功能已经从 Xcode4 中移除(如果我错了,我愿意更正)。

There is, however, a workaround (though this results in the files you're working in get the "M" flag for modified next to them, rather than the "U" flag which means you're working on a previous revision).但是,有一种解决方法(尽管这会导致您正在处理的文件在它们旁边获得“M”标志以进行修改,而不是“U”标志,这意味着您正在处理以前的修订版)。

In XCode4, on the toolbar at the top, select View>>Editor>>Version.在 XCode4 中,在顶部工具栏上,select 查看>>编辑器>>版本。

在此处输入图像描述

In this editor, XCode4 shows your class files in two editor windows, one with your local revision and one with the latest from the repository.在这个编辑器中,XCode4 在两个编辑器 windows 中显示您的 class 文件,一个带有您的本地版本,另一个带有存储库中的最新版本。

At the bottom of each editor window is a toolbar that lists the specific revision you're looking at.在每个编辑器的底部 window 是一个工具栏,列出了您正在查看的特定版本。

在此处输入图像描述

This toolbar is clickable and lets you switch the view to another revision.此工具栏是可单击的,可让您将视图切换到另一个修订版。

在此处输入图像描述

Once you do that, I'm afraid you'll simply have to copy-paste that code into your local class file.一旦你这样做了,恐怕你只需将该代码复制粘贴到你的本地 class 文件中。

This method will ensure that you're working with a working copy of the code.此方法将确保您使用的是代码的工作副本。 However, it may not be the right way to do it (though at the moment, it's the ONLY way).但是,这可能不是正确的方法(尽管目前,这是唯一的方法)。

Two other solutions I have are:我有另外两个解决方案:

1 (not recommended) 1(不推荐)

Work with a copy of XCode 3.2 somehow以某种方式使用 XCode 3.2 的副本

2 (depends on the level of functionality you're looking for) 2(取决于您正在寻找的功能级别)

Download a licensed copy of SmartSVN which let's you update files to specific revisions.下载SmartSVN的许可副本,让您可以将文件更新到特定版本。

You need to do the reverse merge from his revision.您需要从他的修订版中进行反向合并。 Check out this thread: http://www.svnforum.org/threads/31710-how-to-undo-merge-after-svn-update看看这个线程: http://www.svnforum.org/threads/31710-how-to-undo-merge-after-svn-update

Slight offtopic: tired of having similar problems, my team decided to switch to the Mercurial and haven't regretted that even once.稍微偏离主题:厌倦了类似的问题,我的团队决定切换到 Mercurial 并且没有后悔过一次。

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

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