Rename and move files
When you rename or move a file using the Visual Studio Rename option, P4 for Visual Studio prompts you to add the renamed or moved file to a changelist. When you do, P4 for Visual Studio automatically marks the new file name or location for add and the old file name or location for delete. When you submit the changelist, P4 Server creates an integration record that links the renamed or moved object to its deleted predecessor, preserving its history.
To rename a file:
-
In Solution Explorer, right-click the file or folder you want to rename and select Rename.
The file name in Solution Explorer becomes writable.
- Type the new name.
-
When you leave the edit box, P4 for Visual Studio prompts you to add the renamed file to a changelist:
-
Select a pending changelist. The description defaults to the following, but you can change it:
\__path__\__old_filename__ to: \__path__\__new_filename__
- Click Save to Changelist to save the changes.
-
If there are code references to the renamed file in your project, Visual Studio asks if you want to rename all references.
If you click Yes, Visual Studio renames all references, and P4 for Visual Studio prompts you to add the changes to a changelist. Follow the steps listed here to complete the process of submitting those changes to the P4 Server depot.
-
Submit the changelist.
The changelist includes Add operations for the new file name and Delete operations for the old file name.
To learn more about submitting changelists, see Check in files and work with changelists.
To move a file from one location to another:
- Right-click the file you want to move and drag it to the new location.
- P4 for Visual Studio prompts you to add the moved file to a changelist.
-
Select a pending changelist. The description defaults to the following, but you can change it:
\__path__\__old_filename__ to: \__path__\__new_filename_+
- Click Save to Changelist to save the change.
-
Submit the changelist.
The changelist includes Move/Add operations for the new file location and Move/Delete operations for the old file location.
To learn more about submitting changelists, see Check in files and work with changelists.
When you revert a rename or move operation in P4 for Visual Studio, Visual Studio continues to show the new file name or location despite the fact that P4 Server has reverted it to the original name or location, unless you select Update related projects when reverting moved files in the P4 for Visual Studio preferences. To learn more, see Set P4 for Visual Studio preferences.