Monday, April 16, 2012

Merging to Grandparent in TFS2010

I am not a Team Foundation Server (TFS) expert, so I was unpleasantly surprised when I discovered an apparent limitation within it the other day. From what I can see, the TFS merging dialog allows merging changes back to the closest ancestor (parent branch) only. Why is this a problem? Consider the following scenario:
  • Main development happens in the master branch (let's call it "master") 
  • One feature is developed in a "feature" branch which was started from the master some time ago 
  • A small feature bug fix was done in yet another branch "featureSP" which was started from the "feature" branch 
When you try to merge the "featureSP" branch, the dialog will show only one choice for the target: "feature" branch, the parent. This limitation to 3-way merges looks strange.

For a 3-way merge to happen, three check-ins should be sufficient: base, source, and target (source and target should be traceable to base check-in; http://en.wikipedia.org/wiki/Merge_(revision_control)). Source check-in (in our scenario, source it’s "featureSP"—the latest check-in) is traceable to base though both branching operations, so all information is available. I guess this use case has never been considered valuable. I suspect merging changes between sibling branches in TFS may be prone to the same problem, but I haven't tried it yet.

Daniel Sniderman suggested a workaround to this problem by using a baseless merge (from command line with /baseless parameter; see MSDN), thus forcing TFS to use a 2-way merge instead of a 3-way. However, the 2-way merge usually produces a worse result by leaving more unresolvable conflicts. A baseless merge of "featureSP" into "master" would establish a relationship between branches, making future merges easier (from the dialog). I suspect that once the new relationship is established, the old one is lost and merging from "feature" to "master" will bring the same problem again, but I haven’t tried this approach yet.

Other TFS limitations similar to the one described above make branching in TFS a strategic operation that requires planning and coordination. In contrast, Distributed Version Control System (DVCS) keeps branching tactical (even local) and much easier to use; the branch is just a pointer to the commit in the version graph (at least in case of Git). Branches can be created and removed while keeping the version graph the same. Merging in DVCS uses the version graph and does not limit the number of branch pointers between source and base commits.

For a nice comparison of merge algorithms in systems with and without merge metadata (Git and SVN), see Stackoverflow. TFS keeps information about branches and merges (check operation types in Change Details window), so it should merge efficiently.

2 comments:

  1. titanium pickaxe terraria | Tioga Springs, CA
    The ultimate home titanium security of the best titanium pans quality titanium exhaust tubing and comfort in Tioga Springs, CA. Featuring fallout 76 black titanium a convenient check-in and check-out at titanium wood stove the most convenient casinos in Colorado.

    ReplyDelete
  2. This is why Netmarble’s gamble might be going to repay lengthy run|ultimately}. With the company’s capital and advertising sources, it might very well make SpinX not the third but the first in the industry and earn close minimal of} one|to 1} billion annually in three or extra years. For juveniles, in connection to the selective shutdown system mentioned in 1.2 Recent Changes, authorized guardians should be able to|be succesful of|have the flexibility to} check their juveniles’ gaming status, similar to which video games had been accessed and 카지노 쿠폰 for how lengthy.

    ReplyDelete