Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I safely edit a renamed file in perforce

I have a file I need to move that's already under perforce. Once moved it needs some editing - update the package, etc - appropriate to its new location. Should I submit the move changespec and then reopen it for edit, or can I do this in one go? If so, what is the appropriate sequence of events?

like image 865
sblundy Avatar asked Sep 22 '08 14:09

sblundy


1 Answers

I have done this before in one go, but depending on your build process, I recommend against it. What I generally do is this:

  1. Move the file.
  2. If the move needs a change in order to compile, open it for edit and make those changes.
  3. Submit the changes, telling perforce to reopen the files for editing.
  4. Make the changes for path, etc., that don't cause compile errors but should be updated.
  5. Submit those changes with an appropriate description.

If you want to, however, you could just do all your changes in step (2) above. Perforce might change the flag for the new file from integrate to add, but it still remembers the source path for the file.

Edit: Better method

I realized that I often use a different method, but the idea of "moving" the file distracted me. So, I would recommend these steps instead:

  1. Integrate the file into the new path/name, leaving the previous file there. I am assuming that this won't break your build process.
  2. Submit the new file, checking it out again for edit after submission.
  3. Make the required changes to the new file, and to the project so that you are using the new file.
  4. Submit the edits for the new file.
  5. [Optional] You might need to check through branch specs to see if you need to map the old file into the new one in any branches.
  6. Create a changelist for deleting the old file, and submit it sometime later.

This method allows the edits to be cleanly separated from the rename/move, while never leaving the project in a state that won't compile.

Also, why wait for step 6? Sometimes, especially on bigger projects, you might want to move a file that another person is editing. Perforce will helpfully tell you this. By waiting to delete the file, you allow your coworker(s) to finish the edits and submit without needing to move their work manually. After the edits are submitted, they can be integrated into the new file, and then the old one can be safely deleted.

like image 135
Caleb Huitt - cjhuitt Avatar answered Sep 21 '22 01:09

Caleb Huitt - cjhuitt