12

背景:有人在一个正在积极开发的大型 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 来移动文件并将正确的命令粘合在一起。我需要一个自动化的解决方案,因为大量用户中可能存在大量未决更改,所有这些更改都受到迁移的影响,而这些都需要尽可能轻松地解决。

我还考虑过调整Working Disconnected From The 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?
4

1 回答 1

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

但是第三个“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
于 2012-08-18T07:54:41.023 回答