I would like to create an extra property for a Work Item "Environment" which I will use to indicate a target branch for which the Work Item is used.

I have managed to add this property. However now I would like to initiate a merge event when the "Environment" property of the Work Item is changed that merges the source changes under that Work Item to the target branch.

Could you give me some pointers how to proceed on this. Can I programmatically initiate a merge

Re: Team Foundation Server - Version Control Automatic Branching on work item change event


Overall, I would not do something like automatic merging, especially based on work item. What are you trying to achieve

Merge as an activity is something that only benefits from human interaction; to define automatic procedure you will have to define and enforce several assumptions (for example, that there are no conflicts to resolve on merge).

Additionally, how are you going to identify source control items to merge Is your work item associated with changeset or files - how do you identify "changes under Work Item"

For merge related information you may see the following thread.

Regards, Eugene

Re: Team Foundation Server - Version Control Automatic Branching on work item change event


I'm looking into how to migrate our current worklow process into Team System.

Currently we have another tool that combines source control with tasks (similar to work items) that exist in a specific "branch".

To these tasks, files/changesets can be linked. Then these tasks can be transferred to other branches taking with them the source changes. This transferring can be done by any user of the system with enough priveleges. So a tester can transfer the task to a test environment thereby activating the changes in the environments he uses.

These actions are currently trivial activities in our development process. I am looking to achieve a somewhat similar situation in Team System.

I will probably enforce that changes in sources need to be linked to a Work Item, but that the changes can only be done directly on one specific branch. Sources in other branches will only be changed by "transferring"a Work Item to another branch. In that way all changesets linked to the Work Items will be merged to the target branch.

So what I want is to "simplify" the process of merging as much as possible, of course there should be warnings when conflicts arise, but these can be dealt with on individual basis. I can't ask testers to deal with changeset merging etc. They work with work items on a more "functional" level, they shouldn't be bothered too much with technicalities, nor should there be a need for a dedicated administrator to do this when it can be automated for 90% of the cases.

Perhaps this is in contradiction of the Team System philosophy of Work Items and source control, but for now this is how I would like to use it.

Thank you for your link to that thread, I didn't find that one myself yet, it looks promising.

Re: Team Foundation Server - Version Control Automatic Branching on work item change event

Mario Rodriguez- MSFT

Just to close out the thread I will add that this is possible in our system and I would recommend utilizing our Object Model. You can download the SDK online and then look at the help files to provide you with more information about the classes and their methods.

If I think, about this what you want is to react to a work item changed event or check in and then look at the field to decide if a merge is needed. If one is needed then you have to compute the correct source and target and execute your merge. If conflicts arise then depending on the type of conflict you resolve the conflict or leave it for team members to resolve.



Re: Team Foundation Server - Version Control Automatic Branching on work item change event

Martin Hinshelwood

TFS Event Handler project now available on CodePlex:

This is a service based system with a front-end allowing the dynamic addition of event handlers for Team System. Users can upload their own custom Handlers as part of an assembly which are then loaded and executed on the server. This application runs in conjunction with TFS (Team Foundation Server) and handles all of the events that are generated by the server.

Re: Team Foundation Server - Version Control Automatic Branching on work item change event

Richard Berg MSFT

Very cool!

edit: I blogged it

Re: Team Foundation Server - Version Control Automatic Branching on work item change event

Abhishek Joshi India

Hi ,

I have a scenario where i want to implement build with branching in TFS.

we have 3 environments Development ,System Test and User Test. my requirments are :

Development env is where all the developer will do check in / check out. System Test env should be branch of Development and also User Test env should be branch of System Test env.

Every day Development build should start autometically.

Whenever a developrer check-in a file he/she must attached a work item with it and the if he/she wants to move this file to System Test they change the status of Work item to migrate to System.

Then I manually start the System Test branch build and this brach would build all the components which have

'Migrate to test" status of their respective work item.

If the build will successfull then all the component should have status Test in System and this env will be ready for testing.......

the same thing should happen for System Test to User Test environment......

I also want to invoke a out of box window service each time a build completed... and want to perform some external task depend on the status of build means i also want to get the build status.......

So please can anybody has any idea how can i achieve this.....with the help of Branching and build completed event handler.