示例#1
0
        private void FilterBranches()
        {
            var relativeRoots    = computeRelativeRoots();
            var branchesToRemove = new HashSet <string>();

            if (_branchFilters != null && _branchFilters.Count != 0)
            {
                branchesToRemove.UnionWith(GlobalBranches.Keys.Where(b => b != "main" && !_branchFilters.Exists(r => r.IsMatch(b))));
            }
            bool finished = false;

            while (!finished)
            {
                finished = true;
                foreach (var toRemove in branchesToRemove)
                {
                    // only branches from which no non-filtered branches spawn can be removed
                    if (GlobalBranches.ContainsKey(toRemove) && !GlobalBranches.Values.Contains(toRemove))
                    {
                        Logger.TraceData(TraceEventType.Information, (int)TraceId.CreateChangeSet, "Branch " + toRemove + " filtered out");
                        finished = false;
                        GlobalBranches.Remove(toRemove);
                        _changeSets.Remove(toRemove);
                    }
                }
            }
        }
示例#2
0
        private void FilterLabels()
        {
            var labelsToRemove = Labels.Values
                                 .Where(l => l.Versions.Exists(v => !GlobalBranches.ContainsKey(v.Branch.BranchName)))
                                 .Select(l => l.Name).ToList();

            foreach (var toRemove in labelsToRemove)
            {
                Logger.TraceData(TraceEventType.Information, (int)TraceId.CreateChangeSet, "Label " + toRemove + " filtered : was on a filtered out branch");
                Labels.Remove(toRemove);
            }

            var relativeRoots = computeRelativeRoots();

            labelsToRemove = Labels.Values
                             .Where(l => {
                // only filter this label if all the versions are not in a root
                return(null == l.Versions.Find(v => {
                    int count = relativeRoots.Where(r => {
                        string name = v.Element.Name;
                        if (name.StartsWith(ClearcaseRoot))
                        {
                            name = name.Substring(ClearcaseRoot.Length);
                        }
                        if (name.StartsWith("\\"))
                        {
                            name = name.Substring(1);
                        }
                        return name.StartsWith(r);
                    }).Count();
                    if (count > 1)
                    {
                        // sanity check
                        throw new Exception("ambiguous roots for " + v);
                    }
                    return count == 1;
                }));
            })
                             .Select(l => l.Name).ToList();
            foreach (var toRemove in labelsToRemove)
            {
                Logger.TraceData(TraceEventType.Information, (int)TraceId.CreateChangeSet, "Label " + toRemove + " filtered : not used in any root");
                Labels.Remove(toRemove);
            }

            foreach (var label in Labels.Values)
            {
                label.Reset();
            }
        }
        private void FilterLabels()
        {
            var labelsToRemove = Labels.Values
                                 .Where(l => l.Versions.Exists(v => !GlobalBranches.ContainsKey(v.Branch.BranchName)))
                                 .Select(l => l.Name).ToList();

            foreach (var toRemove in labelsToRemove)
            {
                Logger.TraceData(TraceEventType.Information, (int)TraceId.CreateChangeSet, "Label " + toRemove + " filtered : was on a filtered out branch");
                Labels.Remove(toRemove);
            }
            foreach (var label in Labels.Values)
            {
                label.Reset();
            }
        }