Perforce - 如何从主分支退出变更列表

Perforce - how to back-out changelist from master branch

我在 perforce 中有以下更改列表:

1 - some work on //depot/A/file
2 - some work on //depot/A/file
3 - branching of //depot/A to //depot/B
4 .... - some work on //depot/A/file

我想在 //depot/B 上退出 changelist 2

我试过以下方法:

p4 sync //depot/B/file@1
p4 edit //depot/B/file
p4 sync //depot/B/file@2
....

但第一行出现错误。

//depot/B/file@1 - no file(s) at that changelist number.

有什么方法可以在不提交到 //depot/A 分支的情况下实现这一点?

你不能简单地从 B 中取出 2,因为它从 A 中作为一个变化(1 和 2)一起出现。

我认为实现这一目标的唯一方法是:

  1. 在 B 上回滚 3(p4 edit //depot/B/file; p4 sync //depot/B/file#0; p4 submit //depot/B/filep4 delete //depot/B/file; p4 submit //depot/B/file
  2. 将 1 从 A 积分到 B
  3. 将 4 从 A 积分到 B

话虽如此,这有两个缺点:

  1. 如果你以后想把2从A重新整合到B,P4会很困惑,因为它知道它已经已经整合了2从A到B
  2. 如果您想从 B 积分回 A,这会将 B 上的 2 的反转传播回 A,这可能不是您想要的。

因此,尽管它更复杂,但还原集成的唯一正确方法正是您不想做的:

  1. 在 A 上回滚 2
  2. 将 A 整合到 B
  3. 在 A 上重新提交 2

根据您尝试同步到 //depot/B/file@1,我假设该文件以前不存在于 //depot/B/...?

如果我的假设是正确的,您将要删除文件:

p4 delete //depot/B/file

并提交。

如果我的假设不正确并且您新分支的文件是@2 或更高版本,那么:

p4 edit //depot/B/file@1
p4 resolve -ay //depot/B/file
p4 submit 

我会这样做:

p4 copy //depot/A/...@1 //depot/B/...
p4 submit
p4 merge //depot/A/...@2 //depot/B/...
p4 resolve -ay
p4 submit
p4 merge //depot/A/... //depot/B/...
p4 resolve -am
p4 resolve
p4 submit

您也可以在单个更改列表中完成所有这些操作,但它会变得有点棘手 - 上面的内容保持简单并留下易于遵循的历史记录(即每个修订显然 "copied from this change," "ignored this change" 或 "merged these changes" 而不是将所有这些操作融合在一起的单一修订)。