当前位置: 首页>>代码示例>>C#>>正文


C# VersionControlServer.QueryMergeRelationships方法代码示例

本文整理汇总了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;
        }
开发者ID:Manuel-S,项目名称:AutoMerge,代码行数:63,代码来源:BranchesViewModel.cs

示例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;
        }
开发者ID:Manuel-S,项目名称:AutoMerge,代码行数:75,代码来源:BranchesViewModel.cs

示例3: GetMergesRelationships

 private static List<ItemIdentifier> GetMergesRelationships(string sourceTopFolder, VersionControlServer versionControl)
 {
     return versionControl.QueryMergeRelationships(sourceTopFolder)
         .Where(r => !r.IsDeleted)
         .ToList();
 }
开发者ID:Manuel-S,项目名称:AutoMerge,代码行数:6,代码来源:BranchesViewModel.cs


注:本文中的Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer.QueryMergeRelationships方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。