删除后如何在 Perforce 中恢复到项目的早期版本?

发布于 2024-11-29 09:49:57 字数 506 浏览 0 评论 0 原文

假设我在 //depot/MyProject 下有一个项目。在变更列表 1001 中,该项目的方向发生了重大变化,改变了它的一切。在2001年的changelist中,它被p4删除d。仓库现在处于更改 3000。

我想将 //depot/MyProject 恢复到更改列表 1000 处的状态。具体来说,我希望修订历史记录记录更改 3001 的事实是变更 1000 的集成 - 即该项目在重大变更之前的最后一个版本。

Perforce 能做到这一点吗?或者我是否必须将其重命名为 //depot/MyProjectOriginal 之类的名称,因为 //depot/MyProject 现在已被所有这些已删除的修订版本所污染?

p4 集成 //depot/MyProject/...@1000 //depot/MyProject/... 的天真尝试失败,并显示“所有修订版本已集成”消息)

Let's say I have a project under //depot/MyProject. At changelist 1001, this project took a major change in direction, changing everything about it. At changelist 2001, it got p4 deleted. The depot is now at change 3000.

I'd like to restore //depot/MyProject back to its state at changelist 1000. Specifically, I'd like the revision history to record the fact that change 3001 is an integration of change 1000 - i.e. the last version of this project before the major change.

Can Perforce do this at all? Or do I have to rename it into something like //depot/MyProjectOriginal, because //depot/MyProject is now tainted with all those deleted revisions?

(the naive attempt to p4 integrate //depot/MyProject/...@1000 //depot/MyProject/... fails with an "all revision(s) already integrated" message)

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

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

发布评论

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

评论(5

浪荡不羁 2024-12-06 09:49:57

您不能强制集成。

你有两个选择:你可以使用changelist 1000作为基础创建一个分支;或同步到更改列表 1000,签出所有文件,然后提交(也称为回滚)。

选项 1

如果您确实想要 1001-3000 之间的更改历史记录(即从更改列表 1000 开始),那么这是更好的选择。使用 P4V,创建一个新的分支规范,然后执行从当前项目到变更列表 1000 处的新分支的集成。这将作为变更列表 3001 提交,当您比较修订版本之间的差异时,您将看不到看到1001-3000 之间的变化。

在 P4 可视化工具中,这将显示为 1000 处的新分支创建。

选项 2

同步到变更列表 1000,签出所有文件,然后提交。不应该有任何冲突需要解决。这将作为变更列表 3001 提交,但是当您查看历史记录时,您将看到所有内容。

我希望这是有道理的,有任何问题,请提问。

You cannot force the integration.

You have two options: you can create a branch using changelist 1000 as the base; or sync to changelist 1000, check out all files, and then submit (a.k.a rolling back).

Option 1

If you do want the history of your changes between 1001-3000 (i.e. a fresh start from changelist 1000) then this is the better option. Using P4V, create a new branchspec and then perform an integrate from your current project to the new branch at changelist 1000. This will be submitted as changelist 3001, when you compare differences between revisions, you will not see of the changes between 1001-3000.

In the P4 visualizer this will appear as a new branch creation at 1000.

Option 2

Sync to changelist 1000, check out all files, and then submit. There should not be any conflicts to resolve. This will be submitted as changelist 3001, however when you review history you will see the everything.

I hope this makes sense, any questions, please ask.

花落人断肠 2024-12-06 09:49:57

我不相信你可以像这样将文件相互集成。我认为你有两个选择。

如果您愿意移动文件,您可以执行以下操作

p4 integ //depot/MyProject/...@1000 //depot/MyOriginal/Project/...

,这会将更改列表 1000 处的 MyProject 集成到新位置。

如果您想将项目保留在同一位置,也可以这样做。在 p4v 中这确实是最简单的 - 您可以右键单击工作区或仓库视图中的文件夹并选择“回滚...”。在随后的对话框中,您可以选择一个更改列表(或日期、修订版等)来将文件夹回滚到。就您而言,我认为您会选择变更列表 1000。将文件粘贴到新的待处理变更列表中(我认为这始终是一个很好的做法)。然后,您可以运行预览(看看会发生什么),将内容保存到新的更改列表(以便您可以在提交之前检查文件内容),或者只是尝试打破并扣动扳机并提交(我通常不会推荐这个)。

华泰

I don't believe that you can integrate files on top of one another like that. I think that you have two options.

If you are willing to move the files, you can do a

p4 integ //depot/MyProject/...@1000 //depot/MyOriginal/Project/...

and that will integrate MyProject at changelist 1000 to the new location.

If you'd like to keep the project at the same place, you can do that as well. It's really easiest in p4v - you can right click on the folder in workspace or depot view and choose "rollback...". In the subsequent dialog, you can then pick a changelist (or date, revision, etc) to roll the folder back to. In your case, I think that you would choose changelist 1000. Stick the files into a new pending changelist (I think that this is always good practice). You can then run a preveiw (to see what would happen), save the contents to a new changelist (so that you can inspect file contents before submitting), or just go for broke and pull the trigger and submit (I generally wouldn't recommend this).

HTH

爱给你人给你 2024-12-06 09:49:57

就这样做:

p4 copy //depot/MyProject/...@1000 //depot/MyProject/...

这也可以制作一个很好的修订图。

Just do:

p4 copy //depot/MyProject/...@1000 //depot/MyProject/...

This also make a nice revision graph.

栀梦 2024-12-06 09:49:57

尽管有一个公认的答案和许多其他解决方案,但它们都不适合我,因为我需要回滚一个大目录(包含 GB 的数据),

这是我使用的方法,对于大目录效果很好:
(建议在一个新的、干净的工作空间中执行,但不是严格要求)

假设要回滚的目录是 //depot/foo/bar 并且您想要回滚到变更列表 1234

  • 确保没有人锁定任何文件,并确保您尝试回滚的目录存在于您的客户端规范中
  • p4 copy -v //depot/foo/bar/...@1234 //depot/foo/bar/...
  • p4提交

p4 copy -v 是解决方案的核心。它告诉 Perforce 服务器执行虚拟复制,这意味着 Perforce 复制文件,但实际上并不复制到您的工作空间中。这可以避免文件内容的大量数据传输(复制和提交时)。就我而言,通过在 P4V 中使用“回滚”(正在进行非虚拟复制),仅复制就花费了一个多小时,提交文件夹也花费了一个多小时。使用虚拟副本,整个过程花了我大约 1 分钟。

最重要的是,它保留了合理的历史。您可以看到您的文件正在更新和回滚,并且所有以前的历史记录都存在。

Though there is an accepted answer and plenty of other solutions, none of them works for me coz I need to rollback a large directory (with GBs of data)

Here is the way I used, which works fine for huge directory:
(Suggested to do in a new and clean workspace, though not strictly required)

Assuming the directory to rollback is //depot/foo/bar and you want to rollback to changelist 1234

  • Make sure no one is locking any files, and make sure the directory you are trying to rollback exists in your client spec
  • p4 copy -v //depot/foo/bar/...@1234 //depot/foo/bar/...
  • p4 submit

p4 copy -v is the meat of the solution. It tells Perforce server to perform virtual copy, which means Perforce copies the files but not actually in your workspace. This avoid huge data transfer for file content (when copying and when submitting). In my case, by using "rollback" in P4V (which is doing non-virtual copy), it took over an hour just for copy, and over an hour for submit for my folder. With virtual copy, whole process took me around 1 minute.

The most important thing is, it keep a sensible history. You can see your files being updated and rolled back, and all previous history exists.

听不够的曲调 2024-12-06 09:49:57

使用
p4集成-f //depot/MyProject/...@1000 //depot/MyProject/...

-f标志意味着强制集成,即使它们已经被集成。
来自http://www.perforce.com/perforce/doc。当前/手册/cmdref/integrate.html

use
p4 integrate -f //depot/MyProject/...@1000 //depot/MyProject/...

The -f flag means force an integration even if they have already been integrated.
From http://www.perforce.com/perforce/doc.current/manuals/cmdref/integrate.html

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