Perforce:如何在文件被另一个提交的更改移动时解决挂起的更改

Day*_*Day 11 perforce

上下文:有人在正在开发的大型Perforce仓库上进行一些重组工作,并且p4 move在他们仍在处理的情况下编写文件.其他人都需要保留其挂起的更改,但将它们移动到新目录结构中的新位置.

考虑我的挂起的更改列表,包括各种文件的添加,编辑,删除移动.

如果其他用户将p4 move所有这些文件中的一个提交到子目录中,而我的更改列表仍处于待处理状态,我该如何解决,以便对新位置中的相同文件应用相同的更改?

在其他用户移动文件之后,我执行了一个p4 sync将文件放在我的工作区中的新位置,p4 resolve只是说有No file(s) to resolve.

我试图为p4 move path newdir/path我的更改中的每个文件执行一个,这不是很有效:

  • 我添加的文件被移动到新位置添加.好.
  • 我编辑过的文件需要使用-f标志p4 move(没有你得到//depot/newdir/path - is synced; use -f to force move).好.
  • 我删除的文件无法移动(//depot/path - can't move (already opened for delete)).坏
  • 我移动的文件无法再移动.如果我的待定更改正在转移//depot/path//depot/newpath另一个更改已经移动//depot/path//depot/newdir/path那时我可以p4 move newpath newdir/newpath选择更改的"移动/添加"部分,但我也不能p4 move path newdir/path选择更改的"移动/删除"部分(与前一点相同的错误).坏.

如果裸p4命令不起作用,我将不得不破坏bash-fu来移动文件并将正确的命令粘合在一起.我需要一个自动化解决方案,因为在移动中受到影响的大量用户可能会有大量待定更改,这些都需要尽可能轻松地解决.

我还考虑过使用Perforce Server方法中的工作断开连接以在新位置应用我的更改,但这会丢失"移动"元数据,更重要的是,如果多个人必须做同样的事情,这将无法工作如果我在他们面前进入,他们将不得不解决我所做的改变.

如果你想玩玩具示例,这里是我的再现测试用例步骤:

# 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?
Run Code Online (Sandbox Code Playgroud)

use*_*341 7

从理论上讲,您现在应该可以这样做:

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
Run Code Online (Sandbox Code Playgroud)

但是第三个'p4 move'似乎有一个错误,它正在删除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
Run Code Online (Sandbox Code Playgroud)

  • `p4 fstat`给出了所需的移动信息. (2认同)