tags:

views:

1304

answers:

5

My shop uses TFS & is generally happy with it with the exception of the lack of local repository commits/reverts. I'm starting to use Mercurial locally myself to help manage smaller chunks of changes, then posting them to TFS. I see that Subversion has a 'bridge' component to automagically enable this if the central VCS is Subversion. I have not found one for Team System. This encourages me that other folks have gone down this path with integrating DVCS with CVCS systems.

(1) Does anyone know of one? I'm sort of doubting it (quick search didn't find anything).

(2) Is anyone using Mercurial/TFS in this manner? If so, can you share your experiences. I'm particularly looking for any insights into what issues might come up that aren't obvious regarding commits to TFS after significant activity via Mercurial.

It seems like a total win-win so far with just me using if for a few days--but I know enough then to think it's just that easy.

A: 

I know that some people have used hgsubversion with the Subversion bridge. I don't know how well it worked, and I've never had to use TFS.

As far as I'm aware, there's no "more native" bridge than using TFS -> Subversion Bridge -> hgsubversion, but I've also heard that it works fairly well. My extremely limited understanding of TFS suggests that its internal model should be similar enough to Subversion for things like hgsubversion to work really well.

durin42
+9  A: 

Not sure if this is anything you don't already know, but I've been using mercurial locally for a little while now, and so far I think the benefits are outweighing the added overhead of managing the two source control systems. Here is how I've been doing things:

  1. I made my TFS checkout an HG repository which I consider my "master". I get updates from TFS and commit them to this repo, so this contains the most current state of the project from TFS. The important thing here is that there are no changes to this made idependent of a TFS update or an Hg merge (which is part 2)

  2. Anytime I need to make a change, I clone my "master" repo and do my work there. I've found that a clone per feature or story is actually pretty easy to manage, and feels pretty clean. Once I complete a feature, I do an Hg merge back to the "master" repo, which has had all of the TFS updates applied. This allows me to use Mercurials merge capabilities, which are so far superior to TFS as to call into question how TFS can claim to merge code at all. Once the merge is complete, I commit it in Hg, and then check those changes into TFS. The best part of this is that when I do the checkin to TFS, I do not have to merge anything. Very, very nice.

Now, here are the issues I've found with this approach:

  1. The biggest is the fact that TFS is lousy at finding changes. There is a make writable plugin which you can use to make the modified files writable when they are updated/merged by Mercurial. There are two options I have found for this. You can either force TFS to go offline, at which point it will assume anything writable needs to be checked in, or you can use the compare tool in the source control tool and select the changed files and individually check them out. Both are crappy IMO

  2. The source control bindings are still there at the project level, even if you exclude the TFS source control files from your hg repository (which you should do). This isn't entirly obvious until you add a file to the solution, at which point it tries adding it to source control. You can "Undo Pending Changes" and get rid of the source control add, but it's really annoying.

The good news is that I used this approach to work through a rather massive merge which I think would have caused me to turn to some form of hard drugs had I been forced to use the TFS tools to do it.

I have not yet applied this to updating branches within TFS, but my guess would be that it would be much much better than the options you are given for merging in TFS. On a related note, since you can check in chunks of working functionality at one time, using the TFS merge would be less problematic just because all changes needed for a feature would be together in one place.

One thing I have not tried to tackle is sharing this across the entire team. Part of the reason is that it really doesn't have to be a team-wide thing. I work remotely, so having a local repository is a big deal, and saves a lot of time. The other members of my dev team may or may not get the same benefit from this approach, but I find it pretty cool that I can without effecting the way they work.

ckramer
i did a similar approach except perforce was the blessed central repo. And the issues you listed exist there as well. I'm trying to adjust my workflow to feature focused and the patch queues functionality so far I've been pretty happy with it.
Tom Willis
Merging sucks less for TFS when you use the built in tool. James Manning has a nice article on how to swap it out for something much better (I like SourceGear's DiffMerge) http://blogs.msdn.com/b/jmanning/archive/2006/02/20/diff-merge-configuration-in-team-foundation-common-command-and-argument-values.aspx
StingyJack
I blogged about my experience using this setup. http://www.lostechies.com/blogs/hex/archive/2010/06/22/using-mercurial-as-a-local-repository-for-team-foundation-server-start-front-n.aspxI added some powershell scripts to automate the use of hg and the TFS powertools. The other extension I used was hg rebase to keep the merging on the HG side really simple. I know have two simple powershell commands. push and pull, which do the heavy lifting of running the hg and tfs commands lines in the correct order.
Eric Hexter
@Eric, thats some good stuff. When I wrote this I wasn't aware of the rebase extension, Its probably going to find its way into my toolbox in the near future though. The powershell commands are awesome, too.
ckramer
I've been thinking about this for a while now, and ... I'm still stuck on how you would handle merging using Mercurial between existing TFS branches. If I make a change in a branch, I'm usually required to merge it to the root with TFS merge. Any ideas on how to leverage the Mercurial repository in that case? Would I need one hg clone-per-TFS-branch? Is there a way to automate the creation of hg clones when someone creates a TFS branch?
Jeramy Rutley
The way I typically work is to do my change in the root, and then merge it into the branch. In that case the workflow is the same, there is just the added step of doing the merge in TFS afterward. Now, if you are unable to do that, then you are probably looking at creating a new Hg repo for your new TFS branch (which I've done in cases where branches are way different), but your still looking at duplicating some work there. What would be nice is to make a change in one Hg repo, merge it into TFS, then push the change to another Hg repo for your other TFS branch. Not sure if that works tho.
ckramer
A: 

I had a good try at getting it working. I could get Git and TFS playing together (link) via svnbridge, but I couldn't get mercurial to work via svnbridge which frustrated me no end. If you manage to get it working let me know, because I personally prefer mercurial over git (though both are great)

Richard Banks
Were you not able to use the Codeplex bits?http://blogs.msdn.com/bharry/archive/2010/01/27/codeplex-now-supports-mercurial.aspx
MrHinsh
As far as I'm aware the mercurial support is a completely separate server from TFS. It's not a bridging arrangement like it is with the Subversion support.
Richard Banks
+1  A: 

If you want to be able to work with a DVCS and TFS, I believe the best way is to install the SVNBridge for TFS, and the use Bazaar, which is, AFAIK the only DVCS that easily integrates with SVN, and since your TFS now looks like a SVN, you magically get Bazaar/TFS integration

Luxspes
You can use also Mercurial to front SVN, details here: http://abdullin.com/journal/2010/3/22/use-tortoisehg-mercurial-with-svn-repository.html
Sean Kearon
+1  A: 

If you're not stuck on mercurial, there is a sweet git/tfs integration project that I've been using called git-tfs. It's very similar to git-svn, but pushes/pulls from TFS instead. Check it out at http://github.com/spraints/git-tfs

jonfuller
Thanks Jon, I'll check it out.
Maggie