Perforce:当文件被另一个提交的更改移动时,如何解决挂起的更改
上下文:有人在一个正在积极开发的大型Performce仓库中进行一些重组工作,并且在文件仍在处理时移动文件。其他所有人都需要保留其挂起的更改,但要将它们移动到新目录结构中的新位置 考虑我的挂起变更列表,其中包含各种文件的添加、编辑、删除和移动 如果其他用户提交了所有这些文件的Perforce:当文件被另一个提交的更改移动时,如何解决挂起的更改,perforce,Perforce,上下文:有人在一个正在积极开发的大型Performce仓库中进行一些重组工作,并且在文件仍在处理时移动文件。其他所有人都需要保留其挂起的更改,但要将它们移动到新目录结构中的新位置 考虑我的挂起变更列表,其中包含各种文件的添加、编辑、删除和移动 如果其他用户提交了所有这些文件的p4 move到子目录中,而我的变更列表仍处于挂起状态,我如何解决,以便将相同的变更应用到新位置的相同文件 其他用户移动文件后,我执行p4同步,使文件位于我工作区中的新位置,p4 resolve只是说没有要解析的文件 我已尝
p4 move
到子目录中,而我的变更列表仍处于挂起状态,我如何解决,以便将相同的变更应用到新位置的相同文件
其他用户移动文件后,我执行p4同步
,使文件位于我工作区中的新位置,p4 resolve
只是说没有要解析的文件
我已尝试对更改中的每个文件执行p4移动路径newdir/path
,但这不太有效:
- 我添加的文件将被移动到新位置。好
- 我编辑的文件需要在
上使用p4 move
标志(如果没有它,您将获得-f
)。嗯//depot/newdir/path-已同步;使用-f强制移动
- 无法移动我已删除的文件(
)。坏的//depot/path-无法移动(已打开删除)
- 无法再次移动我已移动的文件。如果我的挂起更改正在从
移动到//depot/path
,而另一个更改已将//depot/newpath
移动到//depot/path
,那么我可以//depot/newdir/path
来选择“移动/添加”更改的一部分,但我无法p4移动newpath newdir/newpath
同时拾取更改的“move/delete”部分(与上一点相同的错误)。糟糕p4 move path newdir/path
# Get p4 client and server, install in path (~/bin for me)
cd ~/bin
wget http://www.perforce.com/downloads/perforce/r12.1/bin.linux26x86/p4
chmod +x p4
wget http://www.perforce.com/downloads/perforce/r12.1/bin.linux26x86/p4d
chmod +x p4d
# Start p4 server in a test area (server dumps files in CWD)
mkdir -p ~/p4test/server
cd ~/p4test/server
p4d&
sleep 3
export P4PORT=localhost:1666
unset P4CONFIG # In case you use elsewhere :)
# Create some default client specs and workspaces for them.
mkdir ../workspace1
cd ../workspace1
export P4CLIENT=client1
p4 client -o | p4 client -i
mkdir ../workspace2
cd ../workspace2
export P4CLIENT=client2
p4 client -o | p4 client -i
# Create files and commit initial depot from client1
cd ../workspace1
export P4CLIENT=client1
for i in 1 2 3 4; do echo "This is file $i" > file$i; done
p4 add file*
p4 submit -d 'Initial files'
# Now make some changes to the files. But do not submit - leave pending.
# Add
echo "New file 0" > file0
p4 add file0
# Edit
p4 edit file1
echo "Edited $(date)" >> file1
# Delete
p4 delete file2
# Move
p4 edit file3
p4 move file3 file3.1
# Pending changelist looks like this:
# p4 opened
#//depot/file0#1 - add default change (text)
#//depot/file1#1 - edit default change (text)
#//depot/file2#1 - delete default change (text)
#//depot/file3#1 - move/delete default change (text)
#//depot/file3.1#1 - move/add default change (text)
# Meanwhile, in client2, another user moves everything to a new dir
cd ../workspace2
export P4CLIENT=client2
p4 sync
p4 edit file*
p4 move ... main/...
p4 submit -d 'Move everything to new "main" directory'
# Now what happens in client1?
cd ../workspace1
export P4CLIENT=client1
p4 sync
# //depot/file4#1 - deleted as /home/day/p4test/workspace1/file4
# //depot/file1#1 - is opened for edit - not changed
# //depot/file2#1 - is opened for delete - not changed
# //depot/file3#1 - is opened for move/delete - not changed
# //depot/file3.1#1 - is opened for move/add - not changed
# //depot/main/file1#1 - added as /home/day/p4test/workspace1/main/file1
# //depot/main/file2#1 - added as /home/day/p4test/workspace1/main/file2
# //depot/main/file3#1 - added as /home/day/p4test/workspace1/main/file3
# //depot/main/file4#1 - added as /home/day/p4test/workspace1/main/file4
# day@office:~/p4test/workspace1$ tree
# .
# ├── file0
# ├── file1
# ├── file3.1
# └── main
# ├── file1
# ├── file2
# ├── file3
# └── file4
#
# 1 directory, 7 files
# Now ... how to resolve?
理论上,您现在应该能够做到这一点:
p4 move -f ... main/... # meld your opened files to their renamed files
p4 move -f main/file3.1 main/file3 # meld your renamed file to their renamed file
p4 revert '*' # revert your now-spurious pending deletes
p4 move main/file3 main/file3.1 # move their renamed file to the name you wanted
p4 resolve # merge their edits with your edits
但是第三个“p4移动”似乎有一个bug,它正在删除main/file3.1(fka main/file3)上的待定解析
但是,如果您按以下顺序操作,它似乎确实可以正常工作:
p4 move -f ... main/...
p4 move -f main/file3.1 main/file3
p4 revert '*'
p4 resolve
p4 move main/file3 main/file3.1
请注意,您需要一个非常新的客户端和服务器版本才能使其正常工作。我用2012.1测试了这个。谢谢。如何自动执行将重命名迁移到新目录的
p4 move
命令(我的玩具示例中的file3=>file3.1,解决方案中的第二个和第三个p4 move
命令)。我必须从p4 opened
的输出中计算出“from”和“to”文件,但这并没有为您提供足够的信息,因此如果列表中有多个文件移动,您就无法计算出来。有什么想法吗?p4 fstat
提供了所需的移动信息。