TFS (2010) to SVN using a modified tfs2svn

UPDATE Jul 15 2012: I have linked my changes at the bottom of the post so you can either grab the bin or the changed files.

====================

Last year I wrote on how our org used tfs2svn to get us out of some jams when our TFS / SvnBridge / ReviewBoard solution was returning errors (Migrate TFS to SVN). We had been using that solution merrily while TFS 2008 Server was in play. Disaster struck when the infrastructure guys upgraded last week to TFS 2010 taking full advantage of the  new TFS 2010 Collections paradigm. What the new Collections does is alter the URL so that part of the path after the domain is the collection and part is the repository path (ex: http://tfsserver:8080/tfs/collection/myProject/trunk where the “http://tfsserver:8080/tfs/collection/” part is the server and collection declaration and the “/myProject/trunk” part is the TFS repository path “$/myProject/trunk”.


When we tried to use tfs2svn again we were getting all sorts of errors such as when using the OpenTF mode:

System.Exception: Error while executing TFS QueryHistory ---> System.Xml.XmlException: '100' is an unexpected token. The expected token is "" or "". Line 20, position 65.

Or when using the MS Team Explorer mode:

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.TeamFoundation.Client, Version-8.0.0.0, Culture=neutral, PublicKeyToken=[string]' or one of its dependencies. The system cannot find the file specified.

What is occurring is that tfs2svn is recognizing that its TFS libraries (v8.0.0.0) are lower than the source TFS server (v10.0.0.0) and it is also programmed to take everything after the domain as the repository path which means it doesn’t handle the Collections portions of the URL. The creator, Kevin Colyar, mentioned in this post (https://sourceforge.net/projects/tfs2svn/forums/forum/772710/topic/4548185) in May 2011 that he will not be supporting the project past TFS 2008. Fortunately the source is available and some people had already made headway getting it to work with TFS 2010 (in the same post). I took what the anonymous posted mentioned and ran with it to great success.

The 2 major things we needed to fix was to update the dependency references (.Net Framework 4 and use the TFS 10.0.0.0 libraries) and to update the code to understand where the Collection part of the URL ends and the repository path part begins.

Steps in a nutshell:

  1. Install Visual Studio 2010 Ultimate (I grabbed the iso from the MSDN account). Takes ~45 mins.
  2. Run VS 2010 and select General Develpment mode if prompted.
  3. Download the Tfs2svn source:
    svn co https://tfs2svn.svn.sourceforge.net/svnroot/tfs2svn/trunk C:tfs2svncode
  4. Open the project (C:tfs2svncodetrunktfs2svn.sln)
  5. Conversion Wizard opens:
    1. Create backup: No
    2. Summary: Finish
  6. In the Solution Explorer right click on each project (ex tfs2svn.Winforms) > Properties > Application tab:
    1. Target framework: .NET Framework 4
    2. Close and reopen to take effect.
    3. Repeat for all projects.
  7. Modified the tfs2svn source code (see diff).
  8. Built to C:tfs2svncodetrunktfs2svn.WinFormsbinRelease
  9. Copy SVN 1.6 (svn-win32-1.6.13) into libssvn-win32-1.6.13.
  10. Modified the tfs2svn.Winforms.exe.config to point to the new libssvn-win32-1.6.13
  11. Run tfs2svn.Winforms.exe.

And voila!

The new field is available and we can distinguish between the server url and the repo path. I essentially added a new field “TFSRepo” to split out the TFS server w collection (http://tfsserver:8080/tfs/collection/) and the repository ($/myProject/trunk). I needed to add the field to the UI, config, and logic code for parsing the paths.

Note: I tried using the OpenTF 0.5.2 alpha libs but they were not working “well”. Perhaps the newer 0.6.0 will work but I didnt try. For this solution use the MS Team Explorer client libs.

Edit: Brandon (comments below) added that TFS Team Explorer needs to be installed then use the MS Team Explorer option in tfs2svn2012. Thanks for testing Brandon!

Bin and Diff

The link below is for the files changes to Rev 106. Checkout rev 106 then replace with the changed files below:
tfs2svncoderev106.zip (66k)
The next link is for the Built binaries. You will need to download a copy of SVN since I didnt include it:
tfs2svnCustomBin.zip (200k)

Advertisements

35 thoughts on “TFS (2010) to SVN using a modified tfs2svn

  1. Hi

    This looks like exactly what I need, although I am not having much luck with the pdf patch file, any chance you can email me the patch file directly.

    Thanks

  2. Needed your mod really bad! Compiled and worked like charm!
    Very big THANK YOU for sharing your work, and writing this article!

  3. I can certainly try to do that but I am not sure if you need to have TFS 2010 libraries installed. I guess this would be a good test. I probably can not host it due to the limited bandwidth that I have. Do you have an FTP or a drop box?

  4. I’d be more than happy to provide FTP or Dropbox credentials! Feel free to email me at my email address I’ve provided in the comments, and I’d be happy you paypal you some beer/pizza cash for the time you’ve put into this.

  5. I have pulled down revision 107 and see some of the changes, however, I don’t see the changes on the UI. Am I missing something?

  6. It doesnt look like they took my changes afterall. Maybe they did not want the UI change. Their rev 107 updated the .Net framework, put SVN 1.7 binaries in, and made some minor changes to the TfsClientProvider.cs in both the OpenTFS and MSTFS packages. I think that you should still be able to use their package but you will not have the server split out from the repo. If you wish to have the UI change take the diff that I supplied and patch it against their rev 107.

  7. Hi Tim,

    I downloaded latest tfs2svn source and made file changes based on your diff file. The build got the following error. Could you please take a look? Do you have a new diff file based on the current version of tfs2svn source?

    —— Rebuild All started: Project: tfs2svn.Winforms, Configuration: Debug Any CPU ——
    C:tfs2svncodetfs2svn.WinFormsfrmMain.cs(216,209): error CS1061: ‘tfs2svn.Winforms.Properties.Settings’ does not contain a definition for ‘SvnBinFolder’ and no extension method ‘SvnBinFolder’ accepting a first argument of type ‘tfs2svn.Winforms.Properties.Settings’ could be found (are you missing a using directive or an assembly reference?)

    Compile complete — 1 errors, 0 warnings
    —— Skipped Rebuild All: Project: tfs2svn.Setup, Configuration: Debug ——
    Project not selected to build for this solution configuration
    ========== Rebuild All: 8 succeeded, 1 failed, 1 skipped ==========

    The new content of Settings.settings file I have:

    https://my-svn-server:8443/svn/MyProject/trunk

    [MyDocuments]tfs2svn

    True

    <?xml version=”1.0″ encoding=”utf-16″?>
    <ArrayOfString xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:xsd=”http://www.w3.org/2001/XMLSchema”>
    <string>DEVdolsthoorn;dion</string>
    <string>DEVkcolyar;kevin</string>
    </ArrayOfString>

    1

    libssvn-win32-1.4.6bin

    http://my-tfs-server:8080/tfs/myCollection

    $/MyProject

  8. I am guessing that if you took the latest tfs2svn code then there is a version mismatch between the /libs that they provide and what is in my config. It also looks as though they removed the svn binaries from the /lib folder so you may need to get those on your own now.

  9. Hi Tim,

    I really don’t know how to get old tfs2svn source. Would you please send me the tfs2svn compiled by you for TFS2010? I highly appreciate your help.

    Thanks and Regards

  10. @Frank Ning
    I will see what I can do on Tuesday morning. It is currently a holiday long weekend in Canada and I am out of town away from my workstation.

  11. Hi Tim,

    Much appreciated. Really hope you enjoyed the long weekend (I had the same long weekend in Toronto:-)). Looking forwards to getting your package/more help …

    Best Regards
    Frank

  12. Hey Tim,

    Do you have the source repo with you patch file available some where to check out and build ? If not, I can add your commits to the 1.0.7 src and post it to some repo and share so folks can just check out and build locally rather going through including each diff.

    Thanks

  13. @Comp:

    I will grab it from work today and bring it home. I will host the source so that you can grab it and contrib it back. That would be great if you could!

  14. @Das: this will only port over the code. You will probably need another utility for migration of admin content. If you do find such a tool please let me know!

  15. Thanks for this Tim! Our dev team is moving from TFS 2010 to SVN and I’m the lucky guy that get to do the migration. I was struggling with finding a method that would convert the datbase over because of the Collections paradigm in TFS 2010. I spent about a day looking into TortiseSVN over SvnBridge – another unfortunately defunct project – until I found this post.

    Just to confirm, I downloaded and built the source for rev 107 (your changes minus the UI) and was able to get the conversion started using the following URL format: http://:8080/tfs//

    The conversion is happily chugging along as I write 🙂

  16. Hi Tim,

    I am new to subversion and I am using this tool to migrate the source code from TFS 2010 to Subversion 1.7. I have used your cusotmized binaries and have replaced them with the original ones. I do get the UI correctly now. But when i give a particular change set number for migration, i just keep getting this particular error
    “2013-02-15 13:19:05,826 INFO Tfs2Svn.Tfs2SvnConverter – Adding folder D:\Repository\ePlannerNGB\\BuildProcessTemplates
    2013-02-15 13:19:05,866 INFO Subversion.SvnImporter – svn add “D:\Repository\ePlannerNGB\\BuildProcessTemplates”
    2013-02-15 13:19:05,906 ERROR Winforms.MainForm – Exception while converting
    System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified
    at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
    at System.Diagnostics.Process.Start()
    at Colyar.SourceControl.Subversion.SvnImporter.RunSvnCommand(String command)
    at Colyar.SourceControl.Subversion.SvnImporter.Add(String path)
    at Colyar.SourceControl.Tfs2Svn.Tfs2SvnConverter.tfsExporter_FolderAdded(Int32 changeset, String path, String committer, String comment, DateTime date)
    at Colyar.SourceControl.SinglePathHandler.Invoke(Int32 changeset, String path, String committer, String comment, DateTime date)
    at Colyar.SourceControl.MicrosoftTfsClient.TfsClientProvider.AddFolder(Changeset changeset, Change change)
    at Colyar.SourceControl.MicrosoftTfsClient.TfsClientProvider.ProcessFolderChange(Changeset changeset, Change change)
    at Colyar.SourceControl.MicrosoftTfsClient.TfsClientProvider.ProcessChange(Changeset changeset, Change change)
    at Colyar.SourceControl.MicrosoftTfsClient.TfsClientProvider.ProcessAllChangeSets()
    at Colyar.SourceControl.Tfs2Svn.Tfs2SvnConverter.Convert()
    at tfs2svn.Winforms.MainForm.DoWork(Object obj)

    Can you please tell me what is going wrong here??

  17. @Preethi: I get those every once and a while. I have a theory that TFS and SVN do not handle adds and deletes in the same order nor do they handle paths in the same order. Also, in the changeset above where you are adding a folder you may be deleting it in a later changeset causing this “The system cannot find the file specified”.

    What I then do for these cases is switch to “manual” mode to get past the error then switch back to tfs2svn again. Open up the problem changeset and look at all of the changes made (adds, deletes, edits etc). Using whatever TFS management program you have, check out that particular problem changeset to another directory then copy over (or delete, edit, etc) file by file as listed in your changeset and mirror the changes into your SVN working copy. Do a diff to be sure everything is the same. Go back to your SVN working copy and run:

    svn status

    and make sure that working changeset mirrors the one in TFS. Grab the commit message from TFS and run:

    svn commit -m “Commit message from TFS”

    Go back into tfs2svn and bump the last Changeset # past the problem changeset then start it again. Hopefully that fixes it for you!

  18. Hi,
    I am seeing that the last update on sourceforge tfs2svn.setp.msi was non 2013-04-29.
    I am also seeing that the trunk is at 2012-02-24.
    Whereas, this blog is dated 2011-12-22.

    Should I download the zip listed on this web blog or the latest tfs2svn.setp.msi on source forge?

  19. For sure grab their latest package but if it doesn’t work then you may be able to diff between theirs and what I have here. I didn’t think that the project was under active dev anymore.

  20. The UI for their latest does not allow me to specify repo path. I do not wish to convert the whole server but just my project.

    Your version which I downloaded thro a link in this blog faces the following problem:

    System.Exception: svn error when executing
    ‘svn propset svn:author –revprop -rHEAD ASDF\Mesa Lisa “C:\projs\ccc”‘.
    Exception: svn: Try ‘svn help’ for more info
    svn: Wrong number of targets specified

    I think the problem is due to author’s windows user name having a space. I believe it would not face that problem if the user name had been MesaLisa. There are too many authors whose username has a space.

    I am looking for the portion of the code that execs the svn cmd above and put quotes around the author’s reference.

    Also, they seemed to have removed rev 106, so I am unable to download it and apply your source patches.

  21. First, big thank you !
    Using your code, and also cleaning up a lot, and making it better, I managed to update tfs2svn to use it with the latest TFS, and SVN.

    It is not using anymore OpenTf at all, is faster, and works better (original work did the hardest part).

    If some people are interested, here is the link to the github repo, where the 2.0 release is available.
    https://github.com/Hartorn/tfs2svn

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s