Ian Ringrose
Ian Ringrose

Reputation: 51927

Workflow for renaming a class when using Visual Studio with Perforce

(I am new to perforce and am trying to avoid getting myself into problems, I have hit problems doing this with other source code control systems)

When I rename I class I need to

What’s the best way to do the above with perforce? What issues to I need to be aware of?

Upvotes: 0

Views: 965

Answers (4)

brgerner
brgerner

Reputation: 4371

I have written a macro for adding a "p4 move -k" action to Visual Sudio's Rename event.
See answer of "How to keep change history while renaming files in Visual Studio using Perforce".

With that macro you can do at least steps 3 and 4 at once by renaming file in Visual Studio.

Upvotes: 0

jop
jop

Reputation: 83990

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

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

  1. First, checkout the files in Perforce. This will clear the readonly flags for those files and let Resharper modify the files as part of the move.
  2. Use Resharper's Move refactoring and move the classes to the new directory.
  3. The previous step also moved the files from the old folder to the new folder. So now we have to fix that so we can do also do the move operation in Perforce. Use Windows Explorer (or whatever is your favorite tool) to move the files from the new location back to the old location.
  4. Go to Perforce and using the Rename/Move context menu to move the files. This will create a pair entries in the changelist for each file; the first entry is for deleting the file from the original folder and the second entry is for adding it to the new one.

Upvotes: 2

user100766
user100766

Reputation:

Have you had a look at the Visual Studio integration (P4SCC) that's available on the Perforce products page? I'd assume that it supports a rename rather nicely (disclaimer: I'm not using Visual Studio with Perforce myself, so I might be wrong).

Upvotes: 0

Caleb Huitt - cjhuitt
Caleb Huitt - cjhuitt

Reputation: 14941

If you have a new enough version of Perforce, it now supports the move command, which will maintain file history across different names. If this is available, your steps are straightforward and should work just fine (from the Perforce side; I'm less experienced with VS).

If you don't have the move command available, you might want to look at this question for a further discussion on renaming/editing files in Perforce.

Upvotes: 2

Related Questions