2012-08-17 56 views
11

上下文:有人在活动开发中的大型Perforce软件仓库上进行了一些重构工作,并且仍在处理它们。其他人都需要保留其未决更改,但将其移至新目录结构中的新位置。Perforce:当文件被另一个提交的更改移动时,如何解决未决的更改

考虑我的待处理更改列表,包括添加,编辑,删除各种文件的移动

如果另一个用户将所有这些文件的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 
# [email protected]:~/p4test/workspace1$ tree 
# . 
# ├── file0 
# ├── file1 
# ├── file3.1 
# └── main 
#  ├── file1 
#  ├── file2 
#  ├── file3 
#  └── file4 
# 
# 1 directory, 7 files 

# Now ... how to resolve? 

回答

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移动'的错误,并且正在删除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 
+1

请注意,你需要为这个漂亮的最近的客户端和服务器版本的工作。我用2012.1测试了这个。 – user1054341 2012-08-18 07:58:16

+0

工作表示感谢。我如何自动执行'p4 move'命令,将命名迁移到新目录(我的玩具示例中为file3 => file3.1,解决方案中为第二个和第三个'p4 move'命令)。我不得不从“p4 opened”的输出中找出“from”和“to”文件,但是这并不能提供足够的信息,所以如果有多个文件移动列表。有任何想法吗? – Day 2012-08-20 09:25:34

+2

'p4 fstat'给出所需的移动信息。 – Day 2012-08-20 10:17:46

相关问题