TFS-SDK: merge does not work

As part of a larger implementation, I am trying to implement the merge operation of my source control branches / folders using the TFS-SDK. I work against installing TFS2010.
What I have:

using System; using Microsoft.TeamFoundation.Client; using Microsoft.TeamFoundation.VersionControl.Client; using Microsoft.TeamFoundation.VersionControl.Common; namespace MergeBranchesFolders { class Program { static void Main() { TfsTeamProjectCollection teamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://TFSSERVER/Collection")); var versionControl = teamProjectCollection.GetService<VersionControlServer>(); const string fromPath = "$/TeamProject/SourceDir"; const string toPath = "$/TeamProject/TargetDir"; Workspace myWorkspace = versionControl.GetWorkspace("WorkspaceName", "WorkspaceOwner"); GetStatus getStatus = myWorkspace.Merge(fromPath, toPath, VersionSpec.Latest, VersionSpec.Latest, LockLevel.None, RecursionType.Full, MergeOptionsEx.None); } } } 

I am convinced that I am getting the correct access to myWorkspace , but getStatus looks like this:

enter image description here
This pretty much says nothing happened.
But if I try to unite in the IDE, I get several merge candidates.
The same merge candidates are also visible if I do:

 var mergeCandidates = versionControl.GetMergeCandidates(fromPath, toPath,RecursionType.Full).ToList(); 

I did not succeed as fromPath / toPath being branches and folders - even with one file.
The only resource I could find was this one that didn't help ...

+4
source share
2 answers

Shai Raiten blog post to the rescue!

This failed:

 GetStatus getStatus = myWorkspace.Merge(fromPath, toPath, VersionSpec.Latest, VersionSpec.Latest, LockLevel.None, RecursionType.Full, MergeOptionsEx.None); 

It succeeded:

 GetStatus getStatus = myWorkspace.Merge(fromPath, toPath, null, null, LockLevel.None, RecursionType.Full, MergeOptionsEx.None); 
+5
source

While the link to the Shai Raiten blog turned out to be useful, the reason for the change was not very clear in the answer above, and in the Shai blog (or in the Microsoft documentation , for that matter). The key here is the meaning of fromVersion and toVersion. It seems that the author made this question the same mistake as me in not understanding the meaning of these parameters. In my case, I realized that the “from” and “to” are links to the source (start point) and target (end point) of the merger, respectively. Although I did not understand why the "to" version should be specified in this case, since in order to actually perform a meaningful merge, the target version should always be a hint. Thus, reading the parameter description as the “initial” and “final” versions did not show me that this contradicted this interpretation.

Finally, I realized that in this case, “from” and “to” refer to the source of the merge, where “from” refers to the start point for a series of change sets and “to” refers to the end point for a series of change sets. If you omit the fromVersion parameter, you say that you want to include all the changes at the beginning (or the last recorded merge), otherwise you say that you want to include only the set of changes coming from the specified version. If you omit "toVersion", then you say that you want to include all changes in the Tip version, otherwise you say that you want to include changes only up to the specified version.

So, in the source code with the fromVersion and toVersion parameters specified as VersionSpec.Latest, you say that you want to merge all the changes that occur between the latest version and the latest version, which by definition does not contain changes. However, in a modified code with a zero value specified for both parameters, you include all available revisions without restrictions.

+4
source

Source: https://habr.com/ru/post/1397827/


All Articles