Do with a file open for ‘add’, if it’s submitted via another client

perforce

With Perforce, I have the following situation:

  • Created a new file foo.txt in client client_a, opened it for add
  • Shelved foo.txt in client_a, unshelved it in client_b
  • Now foo.txt is open for add in client_b
  • Submit foo.txt in client_a

Now my question concerns how I can cleanup foo.txt in client_b. Maybe it has a one line change from the depot version that I'd like to keep. Ideally I'd like to do a resolve operation against the newly checked in file, but I'm not allowed to do this because it's open for add.

Now I have this file foo.txt#1 - add change default in my client.

I can't reopen the file ('nothing changed'), I can't diff it vs the depot ('file not open for edit'), I can't resolve it against the depot ('no files to resolve'), I can't open it for edit ('can't edit, already opened for add').

Is there any way to make perforce reopen this as edit instead of add? I know I can copy it to a temp file, revert, reopen for add, and then recopy the temp file back over, but this seems rather unelegant. Is there any command that can do what I want, or is there a good reason I'm not seeing why it's disallowed?

Best Answer

Only slightly more elegant than the comment in your last paragraph, but you should be able to:

  1. Revert foo.txt in client_b. Since it was marked for add the file will remain on the disk with no changes
  2. Sync foo.txt with -k. This makes the server think you have the latest revision without modifying your local file.
  3. Check out foo.txt for edit. Diff'ing against the have revision should show the changes.
  4. Submit your changes.