开发者

Force Perforce to accept workspace view as valid

I have a number of files checked out with changes ready to submit.

I realised that my client spec was hardcoding my alternate root, so I removed the alternate root from all lines in the client spec, and specified it in the alternate root box instead.

I also had some files not checked out that I wasn't ready to add to changelists so I renamed the directory structure underneath and then synced all branches I needed and then renamed the directory to AltBranch and renamed the old one back.

Now however all the checked out files are listed as "not mapped to workspace view" - they are still there however.

I wanted to force perforce to agree with my version, so I tried p4 sync -k, however I get the error

//.../X.cpp#10 - is opened for edit and can't be deleted

I then tried p4 sync -k -f, but I get the error

//.../X.cpp#10 - refr开发者_如何学Ceshing C:\Work\...\X.cpp
//.../X.cpp#10 - is opened for edit and can't be deleted

On the whole I really like Perforce, however its insistence in always knowing best is frustrating


It's far easier to re-arrange your client mapping when you don't have files checked out. Do you have a spec depot? If so, you can easily get back to the previous version of your client definition by recovering it from the spec depot. Then, submit or shelve your files, so that you can get to a point where you've got no opened files in your workspace. Then, you can re-arrange your client mapping and experiment with different layouts, and Perforce will happily reorder the files on your disk without running into problems with opened files.


I have managed to produce a batch file that contains a sequence of Perforce commands to achieve what I want.

This solution is Windows/DOS specific - although I would imagine other command shells could do the parsing needed for this fix:

 @ echo off
 echo Please Exit Perforce
 pause
 setlocal
 rem Retrieve depot spec format of file
 for /f "delims=# " %%d in ('p4 files %1') do set p4name=%%d
 rem Retrieve current pending changelist
 for /f "tokens=5 delims= " %%d in ('p4 opened %p4name%') do set change=%%d
 p4 revert -k %p4name%
 p4 sync -k %p4name%
 p4 edit -c %change% %1

This version is specific to files, although a directory version would be possible substituting files for dirs

Also stupidly the Command Prompt does not set ERRORLEVEL if the command in the ticks fails.


I think you can do a p4 reopen <changelist> and it should be back to normal.


I had the "not mapped to workspace view" and it turned out I had two mappings in my client spec/workspace that had to be reordered.

bad:

//B/foo/... //mySpec/foo/...
//A/... //mySpec/...

good:

//A/... //mySpec/...
//B/foo/... //mySpec/foo/...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜