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


C# HgRepository.GetHeads方法代码示例

本文整理汇总了C#中HgRepository.GetHeads方法的典型用法代码示例。如果您正苦于以下问题:C# HgRepository.GetHeads方法的具体用法?C# HgRepository.GetHeads怎么用?C# HgRepository.GetHeads使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HgRepository的用法示例。


在下文中一共展示了HgRepository.GetHeads方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CollectAllBranchHeads

        public static Dictionary<string, Revision> CollectAllBranchHeads(string repoPath)
        {
            var retval = new Dictionary<string, Revision>();

            var repo = new HgRepository(repoPath, new NullProgress());
            foreach (var head in repo.GetHeads())
            {
                var branch = head.Branch;
                if (branch == String.Empty)
                {
                    branch = "default";
                }
                if (retval.ContainsKey(branch))
                {
                    // Use the higher rev number since it has more than one head of the same branch.
                    var extantRevNumber = Int32.Parse(retval[branch].Number.LocalRevisionNumber);
                    var currentRevNumber = Int32.Parse(head.Number.LocalRevisionNumber);
                    if (currentRevNumber > extantRevNumber)
                    {
                        // Use the newer head of a branch.
                        retval[branch] = head;
                    }
                    //else
                    //{
                    //    // 'else' case: The one we already have is newer, so keep it.
                    //}
                }
                else
                {
                    // New branch, so add it.
                    retval.Add(branch, head);
                }
            }

            return retval;
        }
开发者ID:StephenMcConnel,项目名称:flexbridge,代码行数:36,代码来源:Utilities.cs

示例2: UpdateToTheDescendantRevision

        /// <summary>
        /// If everything got merged, then this is trivial. But in case of a merge failure,
        /// the "tip" might be the other guy's unmergable data (maybe because he has a newer
        /// version of some application than we do) We don't want to switch to that!
        ///
        /// So if there are more than one head out there, we update to the one that is a descendant
        /// of our latest checkin (which in the simple merge failure case is the the checkin itself,
        /// but in a 3-or-more source scenario could be the result of a merge with a more cooperative
        /// revision).
        /// </summary>
        private void UpdateToTheDescendantRevision(HgRepository repository, Revision parent)
        {
            try
            {
                var heads = repository.GetHeads();
                //if there is only one head for the branch we started from just update
                if (heads.Count(rev => rev.Branch == parent.Branch) == 1)
                {
                    repository.Update(); //update to the tip
                    _sychronizerAdjunct.SimpleUpdate(_progress, false);
                    return;
                }
                if (heads.Count == 0)
                {
                    return;//nothing has been checked in, so we're done! (this happens during some UI tests)
                }

                //  when there are more than 2 people merging and there's a failure or a no-op merge happened
                foreach (var head in heads)
                {
                    if (parent.Number.Hash == head.Number.Hash || (head.Branch == parent.Branch && head.IsDirectDescendantOf(parent)))
                    {
                        repository.RollbackWorkingDirectoryToRevision(head.Number.LocalRevisionNumber);
                        _sychronizerAdjunct.SimpleUpdate(_progress, true);
                        return;
                    }
                }

                _progress.WriteWarning("Staying at previous-tip (unusual). Other users recent changes will not be visible.");
            }
            catch (UserCancelledException)
            {
                throw;
            }
            catch (Exception error)
            {
                  ExplainAndThrow(error, "Could not update.");
            }
        }
开发者ID:JessieGriffin,项目名称:chorus,代码行数:49,代码来源:Synchronizer.cs


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