2

I want to be able to rename classes with associated file in VS without loosing file history in Perforce. I thought I could include an Perforce command (p4 move...) in file renaming of Visual Studio or in class-renaming of ReSharper.

I see 3 options:

Wrap Visual Studio's file-renaming

I extend the file renaming (I mean with file renaming: right-clicking file in Solution Explorer and selecting Rename.) by an own VS add-in or a macro that wraps the existing Rename menu command and calls p4 move....

Extend Visual Studio's file-renaming

I extend the file renaming by any kind of hooking into existing Rename command.

Extend ReSharper's class-renaming

I extend ReSharper's class-rename action (Ctrl+R,R) (with enabled option: Synchronize file names accordingly to changes) by calling p4 move....

Which option is the best one to rename a class with associated file in VS without loosing file history in Perforce?

I have no experience with VS add-ins and ReSharper plug-ins. So if anybody knows that an option is not possible at all than a hint would help me very much.

Any idea?

Dmitry Osinovskiy
  • 9,999
  • 1
  • 47
  • 38
thersch
  • 1,316
  • 12
  • 19

3 Answers3

2

Git handles these types of changes pretty well. Could you move to using Git for your development and using Git-P4 to get the source into Perforce? I don't know Perforce so I'm unsure how well this solution works, but it is definitely something to look into.

Jeff Siver
  • 7,434
  • 30
  • 32
  • Thanks but it is too much effort for me to familiarize myself with Git (and maintain a local version control system) just to get this one feature. – thersch Jul 24 '12 at 17:01
  • Git isn't that difficult to learn; there are a ton of resources out there. Additionally, I'd suspect the cost of learning Git will be less than the cost of writing a VS extension to handle this situation with PerForce. – Jeff Siver Jul 24 '12 at 17:08
  • All developers (several hundred) in our company use one perforce server (with some proxy perforce servers). So P4 is set. If I would use a local Git I would always need to double-check-in my changelists (to local Git and then to Perforce). Or did I misunderstand something? – thersch Jul 24 '12 at 17:14
  • 1
    I believe you have a correct understanding. I still believe you should investigate using Git for development. The workflows it allows are just fantastic and really help productivity. While I don't know P4, I have worked with Subversion and Git is way better. Here's an article comparing Git to SV, most of the advantages indicated should apply to P4 as well as SV http://thinkvitamin.com/code/why-you-should-switch-from-subversion-to-git/ – Jeff Siver Jul 24 '12 at 17:58
  • Jeff thanks a lot for your link. I have just started to read the comparison and am already a little bit impressed about Git. – thersch Jul 27 '12 at 10:23
2

You can extend file renaming in VS 2010 by using a macro for adding a "p4 move -k" action to the rename event. See answer of "How to keep change history while renaming files in Visual Studio using Perforce".
This macro calls automatically a p4 rename/move when you do any rename or move action in Visual Studio. So you keep the file history in Perforce.

Community
  • 1
  • 1
brgerner
  • 4,287
  • 4
  • 23
  • 38
1

Do you have the new P4VS plugin? I believe it supports renaming pretty well.

randy-wandisco
  • 3,649
  • 16
  • 11
  • I have tested P4VS for some hours. It can rename classes with files, even forms conrols (aControl.cs, aControl.Designer.cs and aControl.resx) in one go. That is great! Unfortunatly it is very buggy, at least after I have done any *Undo Checkout*. – thersch Aug 16 '12 at 14:21