Here's a document I wrote up for work yesterday. I think it may be generally useful for anyone else out there who is considering moving from
Visual SourceSafe to
Mercurial. This write-up is specific to an organization working in a Windows environment, using Visual Studio 2008 & 2010, and using
bitbucket.org as a back-end for Hg. I also assume you're using
TortoiseHg and
VisualHg.
- Insure all files are checked in to VSS.
- Get a new, full copy of the project from VSS.
- Make all files writable (uncheck read-only flag in Win Explorer).
- At both the solution and project levels, delete all *.SCC files.
- Edit the .SLN file to remove the "SourceCodeControl" section. It should begin with "GlobalSection(SourceCodeControl)" and end with "EndGlobalSection".
- Edit each .CSPROJ file (one in each project folder) and remove all settings starting with "Scc". There should be 4 -- SccProjectName, SccLocalPath, SccAuxPath, and SccProvider.
- In the same folder as the solution file, in Windows Explorer, right-click, and select "Create Repository Here" from the TortoiseHg menu. Make sure "add special files" is checked.
- Edit the new ".hgignore" file and insert contents as per below. You may need to modify this file, depending on the project.
- Optional: create a README.TXT file in the solution folder, describing the project. This will automatically be displayed on the Bitbucket home screen for this repository.
- Right-click in Windows Explorer and select "Hg Commit" from the Tortoise menu.
- Review the list of files shown. If you see anything that shouldn’t be in source control, cancel out and modify the .hgignore file accordingly.
- Click the "All" button to select all files. Enter "Initial Hg Commit" as the comment. Click "Commit".
- When that is done, exit from the commit dialog and review the project in Windows Explorer. Make sure that all files that should be in source control have a green check superimposed over their icon.
- Create a new repository in Bitbucket for the project:
- https://bitbucket.org
- Repositories, Create repository.
- Enter an appropriate name.
- Language should usually be set to C#.
- Make a note of the repository address.
- Back in the main solution folder, right-click and select "Synchronize" from the Tortoise menu.
- Set the remote repository to the address you noted above. Hit the ‘save’ icon, and give this alias a name.
- Hit the "push" button.
- When that is done, check the project page in Bitbucket to make sure the source is all there.
- As a sanity check, create a new temp folder on your hard drive, and pull a new copy of the repository into it.
- Select "clone" from the Tortoise menu.
- Enter the full path to the Bitbucket repo as the source ("https://bitbucket.org/...") and leave the destination as-is.
- When the clone is done, open the project in Visual Studio.
- Go to Tools, Options, Source Control, and switch your plug-in to VisualHg.
- Take a quick look through the files in the solution, and see if any appear to be missing. (A missing file will have a yellow triangle icon overlay.)
- Do a full build of the solution.
- If possible, run a few tests to be sure it’s working. After the build, exit Visual Studio, and bring up the Hg Commit dialog at the root level. If you see any changed files to check in, they are probably temp files that should be excluded. If this is the case, please edit .hgignore accordingly.
- When done, simply delete your temp folder.
- You have now migrated a VSS database to a Hg repository.
Note that I am not retaining version history here, just starting fresh in Hg. If you want to move your version history over, please look at
vss2hg.pl. I tried this out on one of my VSS databases, and it did work, after some tweaking, though it didn't quite manage to get 100% of the data over, and it was a bit confused about dates. I decided that it wasn't worth bothering with it, in my case.
References:
- stackoverflow.com -- how to remove VSS bindings.
- visualstudiohacks.com -- small program to automatically remove bindings.
- stackoverflow.com -- sample .hgignore files for VS 2008
- stackoverflow.com -- sample .hgignore files for VS 2010.
Labels: programming