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


C# Area.GetLocalOrRemoteVersion方法代码示例

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


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

示例1: AcceptHeads

 private static bool AcceptHeads(ClientStateInfo clientInfo, Area ws, out string errorData)
 {
     SharedNetwork.ImportBranches(clientInfo.SharedInfo);
     Dictionary<Guid, Head> temporaryHeads = new Dictionary<Guid, Head>();
     Dictionary<Guid, Guid> pendingMerges = new Dictionary<Guid, Guid>();
     Dictionary<Guid, HashSet<Guid>> headAncestry = new Dictionary<Guid, HashSet<Guid>>();
     foreach (var x in clientInfo.SharedInfo.PushedVersions)
     {
         Branch branch = ws.GetBranch(x.Version.Branch);
         Head head;
         if (!temporaryHeads.TryGetValue(branch.ID, out head))
         {
             var heads = ws.GetBranchHeads(branch);
             if (heads.Count == 0)
                 head = new Head() { Branch = branch.ID, Version = x.Version.ID };
             else if (heads.Count == 1)
                 head = heads[0];
             else
             {
                 // ???
                 Printer.PrintError("OMG 1");
                 errorData = string.Format("Multiple ({0}) heads for branch {1}", heads.Count, branch.ID);
                 return false;
             }
             temporaryHeads[branch.ID] = head;
         }
         if (head.Version != x.Version.ID)
         {
             HashSet<Guid> headAncestors = null;
             if (!headAncestry.TryGetValue(head.Version, out headAncestors))
             {
                 headAncestors = SharedNetwork.GetAncestry(head.Version, clientInfo.SharedInfo);
                 headAncestry[head.Version] = headAncestors;
             }
             if (headAncestors.Contains(x.Version.ID))
             {
                 // all best
             }
             else if (SharedNetwork.IsAncestor(head.Version, x.Version.ID, clientInfo.SharedInfo))
             {
                 headAncestry.Remove(head.Version);
                 pendingMerges[branch.ID] = Guid.Empty;
                 head.Version = x.Version.ID;
             }
             else if (!SharedNetwork.IsAncestor(x.Version.ID, head.Version, clientInfo.SharedInfo))
             {
                 headAncestry.Remove(head.Version);
                 pendingMerges[branch.ID] = head.Version;
                 head.Version = x.Version.ID;
             }
         }
     }
     foreach (var x in pendingMerges)
     {
         if (x.Value == Guid.Empty)
         {
             Printer.PrintDiagnostics("Uncontested head update for branch \"{0}\".", ws.GetBranch(x.Key).Name);
             Printer.PrintDiagnostics(" - Head updated to {0}", temporaryHeads[x.Key].Version);
             continue;
         }
         Branch branch = ws.GetBranch(x.Key);
         VersionInfo result;
         string error;
         result = ws.MergeRemote(ws.GetLocalOrRemoteVersion(x.Value, clientInfo.SharedInfo), temporaryHeads[x.Key].Version, clientInfo.SharedInfo, out error);
         if (result == null)
         {
             // safe merge?
             Printer.PrintError("OMG 2");
             errorData = string.Format("Can't automatically merge data - multiple heads in branch \'{0}\'.\nAttempted merge result: {1}", branch.Name, error);
             return false;
         }
         else
         {
             clientInfo.MergeVersions.Add(result);
             Printer.PrintMessage("Resolved incoming merge for branch \"{0}\".", branch.Name);
             Printer.PrintDiagnostics(" - Merge local input {0}", x.Value);
             Printer.PrintDiagnostics(" - Merge remote input {0}", temporaryHeads[x.Key].Version);
             Printer.PrintDiagnostics(" - Head updated to {0}", result.Version.ID);
             temporaryHeads[x.Key].Version = result.Version.ID;
         }
     }
     // theoretically best
     clientInfo.UpdatedHeads = temporaryHeads;
     errorData = string.Empty;
     return true;
 }
开发者ID:eatplayhate,项目名称:versionr,代码行数:86,代码来源:Server.cs


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