Perforce Public Knowledge Base - Files Deleted Locally Before Submit
Perforce Software logo
Reset Search
 

 

Article

Files Deleted Locally Before Submit

« Go Back

Information

 
Problem

 

I opened-for-add (Marked for Add) all files in a folder, but some were deleted before I submitted them. I am uncertain which files were deleted.

When I try to submit, there are a handful of error messages (too many to check individually). The changelist is not submitted, and Perforce still shows all files as being open. How can this be corrected?

Solution

There are two approaches to solving this issue. The first approach is to revert the "bad" changelist and re-add the files. The second approach applies if reverting the files is impractical.

Method 1

This method applies when you have only added a few files, and they can be reverted easily.

A failed submit results in the creation of a new changelist and the moving of the current default changelist files to that new changelist:

 

C:\Code Test\Perforce>p4 submit -d "add files"
Submitting change 10.
Locking 2 files ...
add //depot/p4config.txt#1
add //depot/t2032t81.tmp#1
open for read: c:\Code Test\Perforce\t2032t81.tmp: The system cannot find the fi
le specified.
Submit aborted -- fix problems then use 'p4 submit -c 10'.
Some file(s) could not be transferred from client.
In this case, the changelist created was "10".

Revert this changelist to undo the botched add, and then delete it.
C:\Code Test\Perforce>p4 revert -c 10 //...
//depot/p4config.txt#none - was add, unlocked and abandoned
//depot/t2032t81.tmp#none - was add, unlocked and abandoned

C:\Code Test\Perforce>p4 change -df 10
Change 10 deleted.

Now re-add the files, and submit.

Method 2

This method is helpful if there are too many files added and you do not wish revert them.

The Perforce command-line client (p4) can read arguments from a file or from standard input by including the -x flag followed by the filename, or "-x -" to read from standard input. By creating a list of files that exist, and passing this to p4 reopen, you can move these files to a new changelist. The files that do not exist remain in the default pending changelist, so they can be reverted easily.

Example

 

  1. Open all the files for add:

     

    p4 add *
    
    //depot/dir/file.0#1 - opened for add
    //depot/dir/file.1#1 - opened for add
    //depot/dir/file.2#1 - opened for add
    //depot/dir/file.3#1 - opened for add
    //depot/dir/file.4#1 - opened for add
    //depot/dir/file.5#1 - opened for add
    //depot/dir/file.6#1 - opened for add
    //depot/dir/file.7#1 - opened for add
    //depot/dir/file.8#1 - opened for add
    //depot/dir/file.9#1 - opened for add
    

    Some are deleted before you submit ...

    del file.2 file.3 file.5 file.8
    

    Your "have-list" on the server still indicates they are open for add.

    p4 opened
    
    //depot/dir/file.0#1 - add default change (text)
    //depot/dir/file.1#1 - add default change (text)
    //depot/dir/file.2#1 - add default change (text)
    //depot/dir/file.3#1 - add default change (text)
    //depot/dir/file.4#1 - add default change (text)
    //depot/dir/file.5#1 - add default change (text)
    //depot/dir/file.6#1 - add default change (text)
    //depot/dir/file.7#1 - add default change (text)
    //depot/dir/file.8#1 - add default change (text)
    //depot/dir/file.9#1 - add default change (text)
    
  2. Create a new changelist. All open files will be added to this changelist, but this is not what you want, so remove all files from the Files section.
    p4 change
    Change 12424 created.
    
  3. Get a list of files, and pipe this to p4 reopen, specifying the changelist you just created. Remember to include the "-x -" to ensure the command-line client reads from standard input. Note, you can use dir, ls, find, or other commands to create the initial list.
    dir/b | p4 -x - reopen -c 12424
    
    //depot/dir/file.0#1 - reopened; change 12424
    //depot/dir/file.1#1 - reopened; change 12424
    //depot/dir/file.4#1 - reopened; change 12424
    //depot/dir/file.6#1 - reopened; change 12424
    //depot/dir/file.7#1 - reopened; change 12424
    //depot/dir/file.9#1 - reopened; change 12424
    
  4. Revert the files still in the default pending changelist. The files that are opened for add that exist in your workspace have been moved to change 12424 in this example. Those that do not exist in your workspace are still in the default changelist, and you can revert them:
    p4 revert -c default ...
    
    //depot/dir/file.2#none - was add, abandoned
    //depot/dir/file.3#none - was add, abandoned
    //depot/dir/file.5#none - was add, abandoned
    //depot/dir/file.8#none - was add, abandoned
    

    After the above revert, only those files that exist on your system are opened for add. They can remain in change 12424, or you can use p4 reopen to move them back to your default pending changelist.

    p4 opened
    
    //depot/dir/file.0#1 - add change 12424 (text)
    //depot/dir/file.1#1 - add change 12424 (text)
    //depot/dir/file.4#1 - add change 12424 (text)
    //depot/dir/file.6#1 - add change 12424 (text)
    //depot/dir/file.7#1 - add change 12424 (text)
    //depot/dir/file.9#1 - add change 12424 (text)
    

In summary: 

 

  • Create a changelist
  • Move real files to that changelist
  • Revert those left behind

Please note, this is a simple example - the only files open in this client workspace are those involved in the problem. If there are other files open in this client workspace, you might need to tailor the file list and the revert steps to exclude other files. Restricting the folders searched, or using pattern-matching utilities, such as grep or findstr, can help with more complex problems.

Related Links

Feedback

 

Was this article helpful?


   

Feedback

Please tell us how we can make this article more useful.

Characters Remaining: 255