Merge programmatically using TeamFoundationClient TFS2008 and VS2010
I have a VS Addin (possibly in the future VSIX) for VS 2010. I want to branch any separate files (sql files) and then merge it programmatically.
I've seen several options:
GetStatus status = workspace.Merge
How do I change TFS programmatic changes?
http://blogs.microsoft.co.il/shair/2009/04/20/tfs-api-part-19-merge/
MergeContent(Conflict, true);
workspace.Merge can show modal dialog for merge (diffmerge.exe I think) and show results (resolving conflicts)? Note: in my case, now I want to show the merge tool.
TFS MergeContent API returns false without showing merge tool
There are tf commands (command line, not C ##
tf diff [erence] itemspec [/ version: versionspec]
tf merge [/ recursive] [/ force] [/ candidate] [/ discard] [/ version: versionspec] [/ lock: none | checkin | checkout] [/ preview] [/ unreasonable] [/ nosummary] [/ noimplicitbaseless] [/ conservative] [/ format: (short | long description)] [/ noprompt] [/ login: username, [password]] destination source
tf resolve [itemspec]
[/ auto: (AutoMerge | TakeTheirs | KeepYours |
OverwriteLocal | DeleteConflict
| KeepYoursRenameTheirs)]
[/ preview] [(/ overridetype: overridetype | / converttotype: converttype] [/ Recursive]
[/ new name: path] [/ noprompt]
[/ login: username, [password]]
any suggestions for merging files and options:
1) show dialog for merging (diffmerge)
2) auto, without show dialog for merging (diffmerge or other?) And conflict resolution.
source to share
Copy vsDiffMerge.exe from Visual Studio installation directory C: \ Program Files (x86) \ Microsoft Visual Studio 12.0 \ Common7 \ IDE inside App Exe file
var mergetool = new ThirdPartyToolDefinition(".*",ToolOperations.Merge,"vsDiffMerge.exe","","/m %1 %2 %3 %4");
var toolcol= ThirdPartyToolDefinitionCollection.Instance.FindTool(".*",ToolOperations.Merge);
if (toolcol == null)
{
ThirdPartyToolDefinitionCollection.Instance.AddTool(mergetool);
ThirdPartyToolDefinitionCollection.Instance.PersistAllToRegistry();
}
var controlsAssembly = Assembly.GetAssembly(typeof(ControlAddItemsExclude));
var vcResolveCoinflictsDialogType = controlsAssembly.GetType("Microsoft.TeamFoundation.VersionControl.Controls.DialogResolveConflicts");
var ci = vcResolveCoinflictsDialogType.GetConstructor(BindingFlags.Instance | BindingFlags.Public, null, new[] { typeof(Workspace), typeof(string[]), typeof(bool) }, null);
var resolveCoinflictsDialog = (Form)ci.Invoke(new object[] { workspace, null, true });
resolveCoinflictsDialog.ShowDialog(parent);
ThirdPartyToolDefinitionCollection.Instance.Remove(mergetool);
ThirdPartyToolDefinitionCollection.Instance.PersistAllToRegistry();
source to share