public static HgFlowStream? GetStreamForBranch(HgFlow hgFlow, string branchName) { var prefix = branchName.Contains("/") ? branchName.SubstringBefore("/") + "/" : branchName; var stream = hgFlow.Where(s => s.Value == prefix).ToList(); if(stream.Count == 0) return null; return stream[0].Key; }
public static bool IsEnabled(HgRepository hgRepository, HgFlow hgFlow) { if(!hgFlow.Enabled) return false; // // Ensure that the "develop" branch is not closed var hgDevelopBranch = hgRepository. GetBranches(). FirstOrDefault(c => !c.Branch.Closed && string.Equals(c.Branch.Name, hgFlow.Development, StringComparison.InvariantCulture)); return hgDevelopBranch != null; }
public static HgRevsetEntry GetPrimaryMergeStreamBranchHead(HgRepository hgRepository, HgFlow hgFlow, HgFlowStream stream) { var primaryMergeStream = GetPrimaryMergeStream(stream); var primaryMergeStreamBranchHead = primaryMergeStream.HasValue ? hgRepository.GetBranchmap(). Where(bm => bm.Branch == hgFlow[primaryMergeStream.Value].TrimEnd('/')). SelectMany(bm => bm.Heads). OrderByDescending(h => h.Revision). FirstOrDefault() : null; return primaryMergeStreamBranchHead; }
private static HgFlow ParseHgFlow(string content) { var hgFlow = new HgFlow(true); foreach(var line in content.ReadLines().Select(l => l.Trim()).Where(l => !string.IsNullOrWhiteSpace(l) && !l.StartsWith("#"))) { if(line.StartsWith("[") && line.EndsWith("]")) { var sectionName = line.SubstringBetween("[", "]"); if(sectionName != "branchname") return new HgFlow(false); } // if else { var propertyName = line.SubstringBefore("=").Trim(); var propertyValue = line.SubstringAfter("=").Trim(); switch(propertyName) { case "master": hgFlow.Master = propertyValue; break; case "develop": case "development": hgFlow.Development = propertyValue; break; case "feature": hgFlow.Feature = propertyValue; break; case "release": hgFlow.Release = propertyValue; break; case "hotfix": hgFlow.Hotfix = propertyValue; break; case "support": hgFlow.Support = propertyValue; break; } // switch } // else } // foreach return hgFlow; }