Thursday, September 16, 2010

Use Mercurial to remove TFS friction

TFS, unfortunately, does some things wrong by default. If the client is anything except Visual Studio, the user experience is abysmal when it comes to commit file changes.

These days I created wireframes in Mockups for all my screens. But checking in those files were so difficult that I routinely procrastinated the task. I have installed TFS Power Tools with its shell extension, but that UI suffers from the same usability issues.

One possible workaround is to use TortoiseHg, which is pretty frictionless. Eric Hexter at LosTechies has an excellent recipe on how to set up Mercurial as a local repository for TFS. He didn’t, however, provide the source code for the Power Shell scripts. I typed them up here with minor adjustments.

Pull.ps1


  1. $projectName = "your-project"  
  2. $tf = "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\tf.exe"  
  3.  
  4. function pull{  
  5.     cd "\your\tfs\folder"  
  6.     &$tf get  
  7.     hg commit -A -m "from tfs"  
  8.     cd "your\working\hg\folder"  
  9.     hg pull --rebase  
  10. }  
  11.  
  12. pull 

Push.ps1


  1. $projectName = "your-project"  
  2. $tfpt = "C:\Program Files (x86)\Microsoft Team Foundation Server 2010 Power Tools\tfpt.exe"  
  3. $tf = "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\tf.exe"  
  4. hg push  
  5. cd "\your\tfs\folder"  
  6. &$tfpt scorch /noprompt /exclude:.hgignore`,*.ps1`,.hg  
  7. hg update -C -y  
  8. &$tfpt online /adds /exclude:.hgignore`,*.ps1`,.hg`,_ReSharper`,bin`,obj`,*.user`,*.suo  
  9. &$tf checkin  
  10. cd "your\working\hg\folder" 

No comments: