从不幸的“svn 副本”中恢复

发布于 2024-07-10 18:32:26 字数 419 浏览 10 评论 0原文

今天下午,在注意到一个损坏的构建以及一些文件看起来像非常旧的版本(大约两周前)的事实后,我检查了 svn 日志。 显然就在今天下午,一位开发人员将旧版本的目录“svn 复制”到了同一目录。 因此,看起来该目录中所有文件的最新版本“ie head”确实很旧,并且所有历史记录“ie log”甚至更旧。

然而,我认为我可以通过使用另一个“svn副本”来恢复(即疾病就是治疗)。 我正在考虑做的是找到完成错误“svn copy”的修订版(例如修订版1234),减去1(1233)并执行以下操作:

svn copy -r 1233 file://path/to/messed/up/dir file://path/to/messed/up/dir

应该恢复最新版本,并获取找回我所有的历史。 我的说法正确吗?

This afternoon, upon noticing a broken build and the fact that some files looked like very old versions (about 2 weeks old), I checked the svn log. Apparently just this afternoon, 1 of the developers did an "svn copy" of a directory from an older revision to the same directory. Thus it appears that the latest version "i.e. head" of all the files in that directory are really old, and all the history "i.e. log" is even older.

However, I think I can recover by using another "svn copy" (i.e. the disease is the cure). What I am considering doing is finding the revision where the bad "svn copy" was done (say rev 1234) , subtracting 1 (1233) and doing:

svn copy -r 1233 file://path/to/messed/up/dir file://path/to/messed/up/dir

That should restore the latest version, as well as get back all my history. Am I right about this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

仙女 2024-07-17 18:32:27

根据 SVN 书籍

svn merge -c -1234

应该可以解决问题。

有一个完整的部分 书中对此进行了介绍。

详细解释:
-c -1234 转换为 -r 1234:1233,这会恢复修订版 1234 中的更改。

According to the SVN book,

svn merge -c -1234

should do the trick.

There's a whole section about this in the book.

The verbose explanation:
-c -1234 translates into -r 1234:1233, which reverts the change from revision 1234.

固执像三岁 2024-07-17 18:32:27

这个复制命令不起作用有两个原因:

  1. 由于目标目录已经存在,svn 将复制请求视为复制到目标目录中; 你不能用 cp 覆盖。 所以这将创建 up/dir/dir。 当创建 dir 的 HEAD 版本时,也必须先进行删除操作。
  2. 它是一个将 HEAD 对象的版本 1233 复制到 up/dir 的请求。但是,HEAD 中的 dir 对象没有修订版 1233; 具有相同路径但具有此类修订的对象已被删除。

要解决此问题,您需要

  1. 删除当前的目录对象:

    svn rm file:///path/to/messed/up/dir 
      
  2. 使用“peg revisions”复制

    svn cp file:///path/to/messed/up/dir@1233 file:///path/to/messed/up 
      

This copy command doesn't work for two reasons:

  1. as the target directory already exists, svn treats the copying request as copying into the target directory; you can't overwrite with cp. So this would create up/dir/dir. When the HEAD version of dir was created, there must have been a remove operation first, also.
  2. it is a request to copy the version 1233 of the HEAD object up/dir.However, the dir object in HEAD did not have a revision 1233; the object with the same path that did have such a revision was removed.

To fix this, you need to

  1. remove the current dir object:

    svn rm file:///path/to/messed/up/dir
    
  2. Copy using "peg revisions"

    svn cp file:///path/to/messed/up/dir@1233 file:///path/to/messed/up
    
澉约 2024-07-17 18:32:27

可能吧,但先备份一下。

实际上,我很想知道为什么你没有可以从已经恢复的每日备份......你的 SVN 存储库肯定足够重要吗?

Probably, but make a backup first.

Actually, I'm left wondering why you don't have a daily backup that you can just restore from already... Your SVN repository is surely important enough for that?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文