本文整理汇总了C#中Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer.QueryMergeRelationships方法的典型用法代码示例。如果您正苦于以下问题:C# VersionControlServer.QueryMergeRelationships方法的具体用法?C# VersionControlServer.QueryMergeRelationships怎么用?C# VersionControlServer.QueryMergeRelationships使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer
的用法示例。
在下文中一共展示了VersionControlServer.QueryMergeRelationships方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTrackMergeInfo
private TrackMergeInfo GetTrackMergeInfo(VersionControlServer versionControl,
IEnumerable<ExtendedMerge> allTrackMerges,
string sourcePath)
{
var result = new TrackMergeInfo
{
FromOriginalToSourceBranches = new List<string>(),
};
var trackMerges = allTrackMerges.Where(m => m.TargetItem.Item == sourcePath).ToArray();
if (!trackMerges.IsNullOrEmpty())
{
var changesetIds = trackMerges.Select(t => t.SourceChangeset.ChangesetId).ToArray();
var mergeSourceBranches = _changesetService.GetAssociatedBranches(changesetIds)
.Select(b => b.Item)
.Distinct()
.ToArray();
if (mergeSourceBranches.Length == 1)
{
result.FromOriginalToSourceBranches.Add(mergeSourceBranches[0]);
var sourceFolder = trackMerges.First().SourceItem.Item.ServerItem;
var comment = trackMerges.First().SourceChangeset.Comment;
if (trackMerges.Length > 1)
{
foreach (var merge in trackMerges.Skip(1))
sourceFolder = FindShareFolder(sourceFolder, merge.SourceItem.Item.ServerItem);
comment = "source changeset has several comments";
}
var sourceMergesRelationships = versionControl.QueryMergeRelationships(sourceFolder)
.Where(r => !r.IsDeleted)
.ToArray();
var sourceTrackMerges = versionControl.TrackMerges(changesetIds,
new ItemIdentifier(sourceFolder),
sourceMergesRelationships,
null);
var sourceTrackMergeInfo = GetTrackMergeInfo(versionControl, sourceTrackMerges, sourceFolder);
if (!sourceTrackMergeInfo.FromOriginalToSourceBranches.IsNullOrEmpty())
{
result.FromOriginalToSourceBranches.AddRange(sourceTrackMergeInfo.FromOriginalToSourceBranches);
result.OriginalComment = sourceTrackMergeInfo.OriginalComment;
result.OriginaBranch = sourceTrackMergeInfo.OriginaBranch;
}
else
{
result.OriginalComment = comment;
result.OriginaBranch = mergeSourceBranches[0];
}
}
else
{
result.FromOriginalToSourceBranches.Add("multi");
result.OriginaBranch = "multi";
result.OriginalComment = "source changeset has several comments";
}
}
return result;
}
示例2: GetMergeRelationships
private static List<MergeRelation> GetMergeRelationships(List<PendingChange> pendingChanges, string[] targetBranches, VersionControlServer versionControl)
{
var mergeRelationships = new List<MergeRelation>();
foreach (var pendingChange in pendingChanges)
{
if (pendingChange.IsAdd || pendingChange.IsBranch)
{
var parentFolder = ExtractFolder(pendingChange.ChangeType, pendingChange.ServerItem, pendingChange.ItemType);
var parentFolderRelationships = versionControl.QueryMergeRelationships(parentFolder);
if (parentFolderRelationships != null)
{
foreach (var parentFolderRelationship in parentFolderRelationships.Where(r => !r.IsDeleted))
{
mergeRelationships.Add(new MergeRelation
{
Item = pendingChange.ServerItem,
Source = parentFolder,
Target = parentFolderRelationship.Item,
TargetItemType = ItemType.Folder,
GetLatesPath = parentFolderRelationship.Item,
Recursively = pendingChange.ItemType == ItemType.Folder
});
}
}
}
else if (pendingChange.IsRename)
{
var shareFolder = FindShareFolder(pendingChange.ServerItem, pendingChange.SourceServerItem);
var shareFolderRelationships = versionControl.QueryMergeRelationships(shareFolder);
var sourceRelationships = versionControl.QueryMergeRelationships(pendingChange.SourceServerItem) ?? new ItemIdentifier[0];
if (shareFolderRelationships != null)
{
foreach (var shareFolderRelationship in shareFolderRelationships.Where(r => !r.IsDeleted))
{
var targetBranch =
targetBranches.FirstOrDefault(branch => shareFolderRelationship.Item.Contains(branch));
if (targetBranch != null)
{
var sourceRelationship = sourceRelationships
.FirstOrDefault(r => r.Item.Contains(targetBranch));
mergeRelationships.Add(new MergeRelation
{
Item = pendingChange.ServerItem,
Source = shareFolder,
Target = shareFolderRelationship.Item,
TargetItemType = ItemType.Folder,
GetLatesPath = sourceRelationship != null ? sourceRelationship.Item : null,
Recursively = true
});
}
}
}
}
else
{
var changeRelationShips = versionControl.QueryMergeRelationships(pendingChange.ServerItem);
if (changeRelationShips != null)
{
foreach (var changeRelationShip in changeRelationShips.Where(r => !r.IsDeleted))
{
mergeRelationships.Add(new MergeRelation
{
Item = pendingChange.ServerItem,
Source = pendingChange.ServerItem,
Target = changeRelationShip.Item,
TargetItemType = pendingChange.ItemType,
GetLatesPath = changeRelationShip.Item
});
}
}
}
}
return mergeRelationships;
}
示例3: GetMergesRelationships
private static List<ItemIdentifier> GetMergesRelationships(string sourceTopFolder, VersionControlServer versionControl)
{
return versionControl.QueryMergeRelationships(sourceTopFolder)
.Where(r => !r.IsDeleted)
.ToList();
}