问题
(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
- Change the class name it’s self
- Get Visual Studio to Refactor all the code that uses the class
- Rename the file in the Visual Studio project
- Rename the file in Perforce
- Check the changes into perforce
- Then maybe merge the change from my working branch into the main branch
What’s the best way to do the above with perforce? What issues to I need to be aware of?
回答1:
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):
- 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.
- Use Resharper's Move refactoring and move the classes to the new directory.
- 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.
- 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.
回答2:
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.
回答3:
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).
回答4:
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.
来源:https://stackoverflow.com/questions/4024807/workflow-for-renaming-a-class-when-using-visual-studio-with-perforce