Workflow for renaming a class when using Visual Studio with Perforce

(I am new to perforce and try not to get into problems, I ran into problems associated with other source control systems)

When I rename class I, I need

  • Change the class name to self
  • Get Visual Studio for Refactor of all code that uses the class
  • Rename the file in a Visual Studio project
  • Rename the file to Perforce
  • Check for changes in perforce
  • Then maybe merging the change with my working branch into the main branch

What is the best way to do this with perforce? What questions do I need to know?

0
source share
4 answers

This is a multi-step process, unfortunately. What you need to do is move it first using resharper and then move it again using perforce.

This is how I do it (in Perforce 9.2 and later):

  • First check the files in Perforce. This will clear the read flags for these files and allow Resharper to modify the files as part of the move.
  • Use the Resharper Move refactoring and move the classes to a new directory.
  • The previous step also moved the files from the old folder to the new folder. So now we have to fix this so that we can do the move operation in Perforce. Use Windows Explorer (or something else is your favorite tool) to move files from the new to the old folder.
  • Go to Perforce and use the Rename / Move context menu to move the files. This will create paired entries in the change list for each file; the first entry is for deleting a file from the original folder, and the second is for adding it to a new one.
+2
source

If you have a fairly new version of Perforce, now it supports the move command, which will support file history for different names. If available, your steps are simple and should work fine (from Perforce, I'm less experienced with VS).

If you don't have a move command available, you can look at this question for further discussion of renaming / editing files in Perforce.

+2
source

Have you looked at Visual Studio Integration (P4SCC), which is available on the product page on the Perforce page ? I would suggest that it supports renaming quite nicely (disclaimer: I do not use Visual Studio with Perforce myself, so I could be wrong).

0
source

I wrote a macro to add the action "p4 move -k" to the Visual Sudio Rename event.
See the answer, "How to save change history when renaming files in Visual Studio using Perforce . "

With this macro, you can do at least steps 3 and 4 right away by renaming the file in Visual Studio.

0
source

All Articles