Refactoring and SourceControl

One of the most common refactorings is to rename members: methods, classes, variables and so on, this kind of refactoring works pretty well when your code is under SourceControl.

There are another kind of refactorings, such as: rename files or change the source tree. Using MS VSS as SourceControl Provider I’ve found a lot of issues, the most popular is to forget to delete the original file, so in the next “GetLatestVersion” from the $/root, you get the old file again.

So, if you need to refactor any kind of FS objects (files, folders, trees) disable SourceControl, make the refactoring, and enable it again. Yes, you will loose your files history (at least in a 1 history per file basis), but this is better that reviewing every action performed by our friend VSS.

Anybody knows how to handle this refactorings with SourceDepot, CVS, PVCS, etc..?

Comments (7)

  1. mvm says:

    i think there will be the same issue for cvs, sd and pvcs, even for clearcase.

  2. Jerry Pisk says:

    I don’t know why it’s an issue with VSS, it can rename files without losing their history. The only issue is that it can only renamed checked-in files, so it’s always a toos between – rename file, check out and refactor or refactor, check in and rename file.

  3. Subversion lets you rename files under source control without losing their history (a must fo refactoring). It also lets you move files and directories around the repository.

    To do it without messing up your working copy, you should check-in immediately before moving/copying/renaming anything. You should also check in immediately afterwards.

  4. Chris says:

    Subversion handles renaming files nicely. I’ve just fallen in love with subversion. Goodbye VSS.

  5. Rido says:

    You can rename files from the VSS interface, but if you do it from VS, the original file is not removed from VSS.

  6. Nairb Cairn says:

    Likewise ClearCase. Any system that treats directories as first class citizens and versions them just like ordinary files will work fine with refactoring.

    Most Java IDEs integrate their refactoring support with version control. I.e. when you use a refactoring like rename class, the file is moved in version control, all references are checked out and updated. This kind of stuff is oddly missing from VS.NET. Maybe it will get better…

  7. Cibra says:

    Recently I start to use the Source Depot tool. In this tool, you can rename the file names without loosing the file history. I think, it is the better way to do that.

Skip to main content