Can I safely edit the renamed file in perforce

I have a file that I need to transfer that already exists. After moving it, some editing is required - updating the package, etc. - corresponding to its new location. Should I send move changespec and then open it again for editing, or can I do it at a time? If so, what is the appropriate sequence of events?

+6
source share
5 answers

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

  • Move the file.
  • If a change is required for compilation, open it for editing and make these changes.
  • Submit the changes with perforce to reopen the files for editing.
  • Make changes to the path, etc. that do not cause compilation errors, but must be updated.
  • Submit these changes with the appropriate description.

If you want, however, you could just make all your changes in step (2) above. Perforce can change the flag to add a new file to add, but it still remembers the original path for the file.

Edit: best method

I realized that I often use a different method, but the idea of ​​"moving" the file distracted me. Therefore, I would recommend the following steps:

  • Integrate the file into the new path / name, leaving the same file there. I assume this will not break your build process.
  • Submit the new file, checking it again for editing after sending.
  • Make the necessary changes to the new file and to the project so that you use the new file.
  • Submit changes for the new file.
  • [Optional] You may need to check the specifications of the branches to see if you want to map the old file to the new one in any branches.
  • Create a list of changes to delete the old file and submit it later.

This method allows you to edit data separately from renaming / moving, without leaving the project in a state that will not be compiled.

Also, why wait for the sixth step? Sometimes, especially in large projects, you can move a file that another person is editing. Perforce will help you. While waiting for a file to be deleted, you allow a colleague (s) to finish editing and submit without having to manually move their work. After making changes, they can be integrated into a new file, and then the old one can be safely deleted.

+7
source

Submit the move change and then open it again for editing (you can also use the reopen option). This is much more readable to the user in the change history.

In addition, recent versions of Perforce check for changes to files after permission. Thus, after completing some corrective actions, complaints can be corrected.

+2
source

I would say always send first, then edit. It is much cleaner and makes it more obvious what is happening in your repository. Then just check the file in a new location and make changes. It also makes it much more obvious that the changes were made to a new place and to everything that it should have worked after renaming.

+1
source

“Safe” is probably an important point here. After renaming or moving the file, it will get the version number “1”, which will look like a new file for your Perforce client. Of course, administrators will be able to get their background, but if the history of editing / version of a file is important to you, it’s a little harder to get an older version.

Update: Thanks to Commodore Jaeger and Greg Whitfield for clarifying the comments.

It was not easy to keep track of what One True Answer is, even from Perforce support, so I decided that I would update all of those found:

  • Perforce stores all versions of each document in its database.
  • If it saves your file as a type of "or", it will save the difference in one version of the file to another, and not to the entire file.
  • If you are viewing a file, do not make any changes to it, and then resubmit it, it will save as a new version with 0 diff. This is customizable, and P4 can be tuned to ignore change list items without any actual differences. You can force this behavior to select "Discard unchanged files ..." before submitting a list of changes.
  • Use "Rename / Move ..." to move files in P4 to track them. Do not copy them using Windows Explorer, and then re-add them to P4.
  • If you use the Rename / Move ... function from the context menu, the “new” file will display the version number “1”, as if it were a new file.
  • However, since P4 saves every function that is executed in a file, you can actually go to any previous revision (and even recover deleted files) using the CLI command "p4 filelog -i"
  • If you want to go to the change history of a moved or renamed file, and you are not an administrator, you can right-click and select its “Revision Graph”, which shows each version of the file, even if it is moved between branches.

In line with Perforce support, simplified tracking of change history by moving branches or folders is often a given feature and is located in their current roadmap.

Answer to Perforce: There is currently no way to move / rename / integrate files and keep accurate file history.

However, if you selected "Integration ..." by right-clicking on the folder you want to provide, the versions of the recently forked folder and base file files will start from version No. 1, but the history of integration between the forked folder and base files and the source folder and the basic files will remain, through which you can track the history of file changes.

0
source

Yes, you can. Just re-edit the forked file (i.e. New). P4Win has a context menu for this ("reopen for editing").

0
source

All Articles