12

The problem with renaming files is that if you want to take advantage of Visual Studio refactoring, you really need to do it from inside Visual Studio.

But most (not all*) version control system also want to be the ones doing the renaming.

One solution is to use integrated source control, but this is not always available, and in some cases is pretty clunky.

I'd personally be more comfortable using source control separately, outside of Visual Studio, but I'm not sure how to manage this question of file renames.

So, for those of you that use Visual Studio, which source control do you use? Do you use a VS integration (which one?) and otherwise, how do you resolve this renaming problem?

(* git is smart enough to work it out for itself)

Benjol
  • 63,995
  • 54
  • 186
  • 268

6 Answers6

5

I use SVN (TortiseSVN as the client) and use the Repair Move command from the commit dialog heavily. This allows me to rename the files within VS and resolve the rename when I'm ready to commit to keep version history.

As far as using the VS integration, like you, I find all VS integration clunky and do not use it.

Aaron Carlson
  • 5,522
  • 4
  • 31
  • 35
  • Especially as VS integration (at least the last time I used it), is checkout-modify-checkin oriented, and increasingly source control tools are get-modify-merge. – Benjol Apr 08 '10 at 07:14
  • Wow, that's great to know. I usually have to do the more complicated: remove from project, svn rename, add back to project shuffle. That means one less step - I'll just have to wait for better VS Integration. – quamrana Apr 08 '10 at 18:36
2

mercurial usually prefers to do the renaming via hg rename however it can also detect renames from an outside source by using hg addremove -s 100 (or less than 100 if you want to match a rename with alterations) so clearly you can let VS do the rename and get mercurial to catchup with addremove.

jk.
  • 13,817
  • 5
  • 37
  • 50
1

We use SVN (TortoiseSVN to be exact), and i am always bothered with the renaming problem. The simplest solution i've found is to remove the files from the project, rename them via TSVN and add them back to the project. You have to manually update includes for renamed header files, but this is relatively easy using find&replace.

erelender
  • 6,175
  • 32
  • 49
  • Removing file from projects will delete it from this disk. So you need to *exclude* it from the project. I do next: first rename class using menu Refactor in VS, then rename file using SVN and after that - add new file to project and remove old one – abatishchev Apr 07 '10 at 13:19
  • Yuck! Sounds horrible either way, though I think that @abatishchev's solution sounds slightly better. – Benjol Apr 07 '10 at 13:49
  • If you right click on a file and select "Remove", VS asks if you want to remove or delete the file. If you select remove, the file does not get deleted. – erelender Apr 07 '10 at 13:52
1

We use Team Foundation Server, and it works with no problems. I've also found that moving to using a fully integrated client has improved my workflow, as I don't need to flip between applications just to do trivial tasks.

Rowland Shaw
  • 37,700
  • 14
  • 97
  • 166
  • Thanks. I guess TFS working with VS is a no-brainer :) I dropped TFS from my 'potentials' list a few years back because of price and installation pain. Maybe I should check again... – Benjol Apr 07 '10 at 13:51
  • @Benjol check next Monday when VS2010 is released - my understanding is that you get TFS with it. – Rowland Shaw Apr 07 '10 at 14:03
1

We develop "Plastic SCM" and the Visual Studio Package supports move operations. But I see your point, I'm getting more and more comfortable with the idea of not having plugins/packages and then have the version control working behind the scenes and simply detecting what happened without having to be "plugged in" into the IDE. In fact we're working on it for next release...

pablo
  • 6,392
  • 4
  • 42
  • 62
0

Besides the above advice, for Visual Studio 2008 I found that after making all global changes to any file being renamed from within VS, including right clicking the file and renaming it, as well as a global search and replace for all strings, replacing the old file name with the new file name, you must, if the file is the initial startup file, right click and select it as "set as default page". Otherwise you'll may well get the "The resource cannot be found." error on runtime.

PaulDecember
  • 167
  • 2
  • 13