Perforce resolve 不能正确处理重命名
Perforce resolve doesn't handle renames correctly
假设我们在库中有这些流
main
/ \
A B
所有这些流都有以下文件:
01.txt: 01
02.txt: 02
我从 A 提交了这两个更改列表。
#1: p4 move 01.txt legacy_01.txt
#2:p4 move 02.txt 01.txt
然后我将这些更改列表复制到主目录。
至此,main的文件如预期。
legacy_01.txt: 01
01.txt: 02
但是,当我向下合并到B时,问题就出现了。
经过一些自动解析后(你 p4 resolve
然后盲目接受所有,甚至使用 p4v 的安全无合并自动解析都没关系),文件变成:
legacy_01.txt: 02
(其他文件被删除)
问题更大,因为即使您使用 p4v 的 Safe automatic 解析也会发生。
当然,我可以仔细调整解析顺序以防止出现这种情况,但为什么这是默认设置?
tl;dr:将文件重命名到彼此的位置然后压缩生成的更改列表是有问题的。
复制到main时出现问题
C:\Perforce\test\seongchan-test>p4 copy A/... main/...
//stream/main/seongchan-test/main/02.txt#1 - delete from //stream/main/seongchan-test/A/02.txt#1,#2
//stream/main/seongchan-test/main/01.txt#1 - sync/integrate from //stream/main/seongchan-test/A/01.txt#1,#3
//stream/main/seongchan-test/main/legacy_01.txt#1 - branch/sync from //stream/main/seongchan-test/A/legacy_01.txt#1
C:\Perforce\test\seongchan-test>p4 opened
//stream/main/seongchan-test/main/01.txt#1 - integrate default change (text)
//stream/main/seongchan-test/main/02.txt#1 - delete default change (text)
//stream/main/seongchan-test/main/legacy_01.txt#1 - branch default change (text)
C:\Perforce\test\seongchan-test>p4 resolved
c:\Perforce\test\seongchan-test\main.txt - copy from //stream/main/seongchan-test/A/01.txt#1,#3
c:\Perforce\test\seongchan-test\main.txt - delete from //stream/main/seongchan-test/A/02.txt#1,#2
c:\Perforce\test\seongchan-test\main\legacy_01.txt - branch from //stream/main/seongchan-test/A/legacy_01.txt#1
请注意,none 个文件已打开以进行“移动”——01->legacy_01
和 02->01
操作的顺序(将由 move/add
和move/delete
以特定顺序发生的动作)由于这两个更改列表的“压缩”而丢失!
这最终会混淆后续的 merge/resolve;它试图一次完成所有操作,它最大的努力是将 02->01
和 01->legacy_01
组合成 02->legacy_01
,考虑到这些操作最初发生的顺序,这实际上不是您想要的英寸
有一个 undoc 设置会在 copy
操作期间警告您:
C:\Perforce\test\seongchan-test>p4 configure set dm.copy.movewarn=1
For server 'any', configuration variable 'dm.copy.movewarn' set to '1'
C:\Perforce\test\seongchan-test>p4 copy A/... main/...
//stream/main/seongchan-test/main/02.txt#1 - delete from //stream/main/seongchan-test/A/02.txt#1,#2
//stream/main/seongchan-test/main/01.txt#1 - sync/integrate from //stream/main/seongchan-test/A/01.txt#1,#3
... can't open as move/add because a file already exists in this location.
//stream/main/seongchan-test/main/legacy_01.txt#1 - branch/sync from //stream/main/seongchan-test/A/legacy_01.txt#1
... can't open as move/add because //stream/main/seongchan-test/main/01.txt is not being opened for delete.
Some files couldn't be opened for move. Try copying from @268 instead?
如果我接受错误消息的建议,我最终会分阶段进行复制,每个阶段都会复制 move
操作之一:
C:\Perforce\test\seongchan-test>p4 revert ...
//stream/main/seongchan-test/main/legacy_01.txt#none - was branch, deleted
//stream/main/seongchan-test/main/01.txt#1 - was integrate, reverted
//stream/main/seongchan-test/main/02.txt#1 - was delete, reverted
C:\Perforce\test\seongchan-test>p4 copy A/...@268 main/...
//stream/main/seongchan-test/main/01.txt#1 - move/delete from //stream/main/seongchan-test/A/01.txt#1,#2
//stream/main/seongchan-test/main/legacy_01.txt#1 - move/add/sync from //stream/main/seongchan-test/A/legacy_01.txt#1
C:\Perforce\test\seongchan-test>p4 submit -d "copy from A@268"
Submitting change 271.
Locking 2 files ...
move/delete //stream/main/seongchan-test/main/01.txt#2
move/add //stream/main/seongchan-test/main/legacy_01.txt#1
Change 271 submitted.
C:\Perforce\test\seongchan-test>p4 copy A/... main/...
//stream/main/seongchan-test/main/02.txt#1 - move/delete from //stream/main/seongchan-test/A/02.txt#1,#2
//stream/main/seongchan-test/main/01.txt#2 - move/add/sync from //stream/main/seongchan-test/A/01.txt#3
C:\Perforce\test\seongchan-test>p4 submit -d "finish copy from A"
Submitting change 272.
Locking 2 files ...
move/add //stream/main/seongchan-test/main/01.txt#3
move/delete //stream/main/seongchan-test/main/02.txt#2
Change 272 submitted.
现在,当我们向下合并到 B 时,它会看到两个移动并尝试解决它们——而不是像 copy
那样尝试“压缩”它们,resolve
会警告你不能同时做这两个:
c:\Perforce\test\seongchan-test\B.txt - resolving move to //stream/main/seongchan-test/B/01.txt
//Samwise-dvcs-1509687817/seongchan-test/B/01.txt - can't move to an existing file
此时的修复与之前类似;您必须一次备份并执行更改列表(在两者之间提交)才能成功合并。
C:\Perforce\test\seongchan-test>p4 merge main/...@271 B/...
//stream/main/seongchan-test/B/01.txt#1 - integrate from //stream/main/seongchan-test/main/legacy_01.txt#1 (remapped from //stream/main/seongchan-test/B/legacy_01.txt)
... must resolve content from //stream/main/seongchan-test/main/legacy_01.txt#1
... must resolve move to //stream/main/seongchan-test/B/legacy_01.txt
C:\Perforce\test\seongchan-test>p4 resolve -as
c:\Perforce\test\seongchan-test\B.txt - merging //stream/main/seongchan-test/main/legacy_01.txt#1
Diff chunks: 0 yours + 0 theirs + 0 both + 0 conflicting
//Samwise-dvcs-1509687817/seongchan-test/B/01.txt - copy from //stream/main/seongchan-test/main/legacy_01.txt
c:\Perforce\test\seongchan-test\B.txt - resolving move to //stream/main/seongchan-test/B/legacy_01.txt
//stream/main/seongchan-test/B/legacy_01.txt - moved from //stream/main/seongchan-test/B/01.txt
C:\Perforce\test\seongchan-test>p4 submit -d "merge from main@271"
Submitting change 273.
Locking 2 files ...
move/delete //stream/main/seongchan-test/B/01.txt#2
move/add //stream/main/seongchan-test/B/legacy_01.txt#1
Change 273 submitted.
C:\Perforce\test\seongchan-test>p4 merge main/... B/...
//stream/main/seongchan-test/B/02.txt#1 - integrate from //stream/main/seongchan-test/main/01.txt#3 (remapped from //stream/main/seongchan-test/B/01.txt)
... must resolve content from //stream/main/seongchan-test/main/01.txt#3
... must resolve move to //stream/main/seongchan-test/B/01.txt
C:\Perforce\test\seongchan-test>p4 resolve -as
c:\Perforce\test\seongchan-test\B.txt - merging //stream/main/seongchan-test/main/01.txt#3
Diff chunks: 0 yours + 0 theirs + 0 both + 0 conflicting
//Samwise-dvcs-1509687817/seongchan-test/B/02.txt - copy from //stream/main/seongchan-test/main/01.txt
c:\Perforce\test\seongchan-test\B.txt - resolving move to //stream/main/seongchan-test/B/01.txt
//stream/main/seongchan-test/B/01.txt - moved from //stream/main/seongchan-test/B/02.txt
C:\Perforce\test\seongchan-test>p4 submit -d "finish merge from main"
Submitting change 274.
Locking 2 files ...
move/add //stream/main/seongchan-test/B/01.txt#3
move/delete //stream/main/seongchan-test/B/02.txt#2
Change 274 submitted.
与副本一样,我们可以看到现在每个合并操作都“重放”源的移动操作之一;它们必须一次发生一个,因为第二次合并需要将文件移动到第一次删除的路径中。
假设我们在库中有这些流
main
/ \
A B
所有这些流都有以下文件:
01.txt: 01
02.txt: 02
我从 A 提交了这两个更改列表。
#1: p4 move 01.txt legacy_01.txt
#2:p4 move 02.txt 01.txt
然后我将这些更改列表复制到主目录。 至此,main的文件如预期。
legacy_01.txt: 01
01.txt: 02
但是,当我向下合并到B时,问题就出现了。
经过一些自动解析后(你 p4 resolve
然后盲目接受所有,甚至使用 p4v 的安全无合并自动解析都没关系),文件变成:
legacy_01.txt: 02
(其他文件被删除)
问题更大,因为即使您使用 p4v 的 Safe automatic 解析也会发生。 当然,我可以仔细调整解析顺序以防止出现这种情况,但为什么这是默认设置?
tl;dr:将文件重命名到彼此的位置然后压缩生成的更改列表是有问题的。
复制到main时出现问题
C:\Perforce\test\seongchan-test>p4 copy A/... main/...
//stream/main/seongchan-test/main/02.txt#1 - delete from //stream/main/seongchan-test/A/02.txt#1,#2
//stream/main/seongchan-test/main/01.txt#1 - sync/integrate from //stream/main/seongchan-test/A/01.txt#1,#3
//stream/main/seongchan-test/main/legacy_01.txt#1 - branch/sync from //stream/main/seongchan-test/A/legacy_01.txt#1
C:\Perforce\test\seongchan-test>p4 opened
//stream/main/seongchan-test/main/01.txt#1 - integrate default change (text)
//stream/main/seongchan-test/main/02.txt#1 - delete default change (text)
//stream/main/seongchan-test/main/legacy_01.txt#1 - branch default change (text)
C:\Perforce\test\seongchan-test>p4 resolved
c:\Perforce\test\seongchan-test\main.txt - copy from //stream/main/seongchan-test/A/01.txt#1,#3
c:\Perforce\test\seongchan-test\main.txt - delete from //stream/main/seongchan-test/A/02.txt#1,#2
c:\Perforce\test\seongchan-test\main\legacy_01.txt - branch from //stream/main/seongchan-test/A/legacy_01.txt#1
请注意,none 个文件已打开以进行“移动”——01->legacy_01
和 02->01
操作的顺序(将由 move/add
和move/delete
以特定顺序发生的动作)由于这两个更改列表的“压缩”而丢失!
这最终会混淆后续的 merge/resolve;它试图一次完成所有操作,它最大的努力是将 02->01
和 01->legacy_01
组合成 02->legacy_01
,考虑到这些操作最初发生的顺序,这实际上不是您想要的英寸
有一个 undoc 设置会在 copy
操作期间警告您:
C:\Perforce\test\seongchan-test>p4 configure set dm.copy.movewarn=1
For server 'any', configuration variable 'dm.copy.movewarn' set to '1'
C:\Perforce\test\seongchan-test>p4 copy A/... main/...
//stream/main/seongchan-test/main/02.txt#1 - delete from //stream/main/seongchan-test/A/02.txt#1,#2
//stream/main/seongchan-test/main/01.txt#1 - sync/integrate from //stream/main/seongchan-test/A/01.txt#1,#3
... can't open as move/add because a file already exists in this location.
//stream/main/seongchan-test/main/legacy_01.txt#1 - branch/sync from //stream/main/seongchan-test/A/legacy_01.txt#1
... can't open as move/add because //stream/main/seongchan-test/main/01.txt is not being opened for delete.
Some files couldn't be opened for move. Try copying from @268 instead?
如果我接受错误消息的建议,我最终会分阶段进行复制,每个阶段都会复制 move
操作之一:
C:\Perforce\test\seongchan-test>p4 revert ...
//stream/main/seongchan-test/main/legacy_01.txt#none - was branch, deleted
//stream/main/seongchan-test/main/01.txt#1 - was integrate, reverted
//stream/main/seongchan-test/main/02.txt#1 - was delete, reverted
C:\Perforce\test\seongchan-test>p4 copy A/...@268 main/...
//stream/main/seongchan-test/main/01.txt#1 - move/delete from //stream/main/seongchan-test/A/01.txt#1,#2
//stream/main/seongchan-test/main/legacy_01.txt#1 - move/add/sync from //stream/main/seongchan-test/A/legacy_01.txt#1
C:\Perforce\test\seongchan-test>p4 submit -d "copy from A@268"
Submitting change 271.
Locking 2 files ...
move/delete //stream/main/seongchan-test/main/01.txt#2
move/add //stream/main/seongchan-test/main/legacy_01.txt#1
Change 271 submitted.
C:\Perforce\test\seongchan-test>p4 copy A/... main/...
//stream/main/seongchan-test/main/02.txt#1 - move/delete from //stream/main/seongchan-test/A/02.txt#1,#2
//stream/main/seongchan-test/main/01.txt#2 - move/add/sync from //stream/main/seongchan-test/A/01.txt#3
C:\Perforce\test\seongchan-test>p4 submit -d "finish copy from A"
Submitting change 272.
Locking 2 files ...
move/add //stream/main/seongchan-test/main/01.txt#3
move/delete //stream/main/seongchan-test/main/02.txt#2
Change 272 submitted.
现在,当我们向下合并到 B 时,它会看到两个移动并尝试解决它们——而不是像 copy
那样尝试“压缩”它们,resolve
会警告你不能同时做这两个:
c:\Perforce\test\seongchan-test\B.txt - resolving move to //stream/main/seongchan-test/B/01.txt
//Samwise-dvcs-1509687817/seongchan-test/B/01.txt - can't move to an existing file
此时的修复与之前类似;您必须一次备份并执行更改列表(在两者之间提交)才能成功合并。
C:\Perforce\test\seongchan-test>p4 merge main/...@271 B/...
//stream/main/seongchan-test/B/01.txt#1 - integrate from //stream/main/seongchan-test/main/legacy_01.txt#1 (remapped from //stream/main/seongchan-test/B/legacy_01.txt)
... must resolve content from //stream/main/seongchan-test/main/legacy_01.txt#1
... must resolve move to //stream/main/seongchan-test/B/legacy_01.txt
C:\Perforce\test\seongchan-test>p4 resolve -as
c:\Perforce\test\seongchan-test\B.txt - merging //stream/main/seongchan-test/main/legacy_01.txt#1
Diff chunks: 0 yours + 0 theirs + 0 both + 0 conflicting
//Samwise-dvcs-1509687817/seongchan-test/B/01.txt - copy from //stream/main/seongchan-test/main/legacy_01.txt
c:\Perforce\test\seongchan-test\B.txt - resolving move to //stream/main/seongchan-test/B/legacy_01.txt
//stream/main/seongchan-test/B/legacy_01.txt - moved from //stream/main/seongchan-test/B/01.txt
C:\Perforce\test\seongchan-test>p4 submit -d "merge from main@271"
Submitting change 273.
Locking 2 files ...
move/delete //stream/main/seongchan-test/B/01.txt#2
move/add //stream/main/seongchan-test/B/legacy_01.txt#1
Change 273 submitted.
C:\Perforce\test\seongchan-test>p4 merge main/... B/...
//stream/main/seongchan-test/B/02.txt#1 - integrate from //stream/main/seongchan-test/main/01.txt#3 (remapped from //stream/main/seongchan-test/B/01.txt)
... must resolve content from //stream/main/seongchan-test/main/01.txt#3
... must resolve move to //stream/main/seongchan-test/B/01.txt
C:\Perforce\test\seongchan-test>p4 resolve -as
c:\Perforce\test\seongchan-test\B.txt - merging //stream/main/seongchan-test/main/01.txt#3
Diff chunks: 0 yours + 0 theirs + 0 both + 0 conflicting
//Samwise-dvcs-1509687817/seongchan-test/B/02.txt - copy from //stream/main/seongchan-test/main/01.txt
c:\Perforce\test\seongchan-test\B.txt - resolving move to //stream/main/seongchan-test/B/01.txt
//stream/main/seongchan-test/B/01.txt - moved from //stream/main/seongchan-test/B/02.txt
C:\Perforce\test\seongchan-test>p4 submit -d "finish merge from main"
Submitting change 274.
Locking 2 files ...
move/add //stream/main/seongchan-test/B/01.txt#3
move/delete //stream/main/seongchan-test/B/02.txt#2
Change 274 submitted.
与副本一样,我们可以看到现在每个合并操作都“重放”源的移动操作之一;它们必须一次发生一个,因为第二次合并需要将文件移动到第一次删除的路径中。