Renaming and moving Files

When you rename or move a file using the Visual Studio Rename option, P4VS prompts you to add the renamed or moved file to a changelist. When you do, P4VS automatically marks the new file name or location for add and the old file name or location for delete. When you submit the changelist, Helix Server creates an integration record that links the renamed or moved object to its deleted predecessor, preserving its history.

To rename a file:

  1. In Solution Explorer, right-click the file or folder you want to rename and select Rename.

    The file name in Solution Explorer becomes writable.

  2. Type the new name.
  3. When you leave the edit box, P4VS prompts you to add the renamed file to a changelist:

    Rename changelist icon
  4. Select a pending changelist. The description defaults to the following, but you can change it:

    \__path__\__old_filename__ to:
    \__path__\__new_filename__
  5. Click Save to Changelist to save the changes.
  6. 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 P4VS prompts you to add the changes to a changelist. Follow the steps listed here to complete the process of submitting those changes to the Helix Server depot.

  7. Submit the changelist.

    The changelist includes Add operations for the new file name and Delete operations for the old file name.

    For more information about submitting changelists, see Checking in files and working with changelists.

To move a file from one location to another:

  1. Right-click the file you want to move and drag it to the new location.
  2. P4VS prompts you to add the moved file to a changelist.
  3. Select a pending changelist. The description defaults to the following, but you can change it:

    \__path__\__old_filename__ to:
    \__path__\__new_filename_+
  4. Click Save to Changelist to save the change.
  5. Submit the changelist.

    The changelist includes Move/Add operations for the new file location and Move/Delete operations for the old file location.

    For more information about submitting changelists, see Checking in files and working with changelists.

    Note

    When you revert a rename or move operation in P4VS, Visual Studio continues to show the new file name or location despite the fact that Helix Server has reverted it to the original name or location, unless you select Update related projects when reverting moved files in the P4VS preferences. For more information, see Setting P4VS preferences.