Пример #1
0
 public static List<Wish> CloneAndFillInBlanksFrom(IEnumerable<Wish> deps, Wish defaultDep)
 {
     var merged = new List<Wish>();
     foreach (var dep in deps) {
         merged.Add(dep.CloneAndFillInBlanksFrom(defaultDep));
     }
     return merged;
 }
Пример #2
0
 public void AddOrFailIfExists(Wish wish)
 {
     var key = wish.Key;
     if (m_wishesByKey.ContainsKey(key)) {
         throw new ResolverException("Duplicate wish :" + wish);
     }
     m_wishesByKey[key] = wish;
 }
Пример #3
0
 /// <summary>
 /// Add a wish unless there is already a matching constraint
 /// </summary>
 /// <returns>true if added, false if there was already a wish matching the same requirements</returns>
 public bool AddWish(Wish wish)
 {
     if (FilterExistsFor(wish)) {
         return false;
     }
     Log.Trace("Adding " + wish.ToSummary());
     return LocalWishSetFor(wish).AddIfNotExists(wish);
 }
Пример #4
0
        public void MergeInChild(Wish wish)
        {
            var key = wish.Key;

            Wish existing;
            if (m_wishesByKey.TryGetValue(key, out existing)) {
                m_wishesByKey[key] = wish.CloneAndFillInBlanksFrom(existing);
            } else {
                m_wishesByKey[key] = wish;
            }
        }
Пример #5
0
        public override void AfterLoad()
        {
            if (ProjectFormat != SupportedVersion) {
                throw new ArgumentException("This solution only supports format version " + SupportedVersion + ". Instead got " + ProjectFormat);
            }
            base.AfterLoad();

            //Apply defaults
            WishDefaults = WishDefaults == null ? DefaultWishValues.Clone() : WishDefaults.CloneAndFillInBlanksFrom(DefaultWishValues);
            WishDefaults.Scope = Scopes.Transitive;

            //CompileWishes = Wish.CloneAndFillInBlanksFrom(CompileWishes, WishDefaults);
            RuntimeWishes = PostProcess(RuntimeWishes, WishDefaults, Scopes.Runtime);
            ProvidedWishes = PostProcess(ProvidedWishes, WishDefaults, Scopes.Provided);
            OptionalWishes = PostProcess(OptionalWishes, WishDefaults, Scopes.Transitive);
            TransitiveWishes = PostProcess(TransitiveWishes, WishDefaults, Scopes.Transitive);

            ValidateReadyForMerge(RuntimeWishes);
            ValidateReadyForMerge(ProvidedWishes);
            ValidateReadyForMerge(OptionalWishes);
            ValidateReadyForMerge(TransitiveWishes);
        }
Пример #6
0
 public NewModule RuntimeWishWith(Wish wish)
 {
     base.RuntimeWishes.Add(wish);
     return this;
 }
Пример #7
0
 public NewModule TransitiveWishWith(Wish wish)
 {
     base.TransitiveWishes.Add(wish);
     return this;
 }
Пример #8
0
 private static Key Key(Wish wish)
 {
     return wish.Key;
 }
Пример #9
0
 /// <summary>
 /// Parse from  group:name:version:ext:classifiers:scope
 /// </summary>
 /// <param name="fullString">Full string.</param>
 public static Wish Parse(String fullString)
 {
     var wish = new Wish();
     wish.SetAllFromParse(fullString);
     return wish;
 }
Пример #10
0
 private void InternalFillInBlanksFrom(Wish wish)
 {
     if (wish == null) {
         return;
     }
     InternalFillInSimpleBlanksFrom(wish);
 }
Пример #11
0
        private void InternalFillInSimpleBlanksFrom(Wish fromWish)
        {
            if (fromWish == null) {
                return;
            }
            var modified = false;
            if (String.IsNullOrWhiteSpace(this.Group) && !String.IsNullOrWhiteSpace(fromWish.Group)) {
                this.Group = fromWish.Group;
                modified = true;
            }
            if (String.IsNullOrWhiteSpace(this.Name) && !String.IsNullOrWhiteSpace(fromWish.Name)) {
                this.Name = fromWish.Name;
                modified = true;
            }
            if (String.IsNullOrWhiteSpace(this.Ext) && !String.IsNullOrWhiteSpace(fromWish.Ext)) {
                this.Ext = fromWish.Ext;
                modified = true;
            }
            if (this.Url == null && fromWish.Url != null) {
                this.Url = fromWish.Url;
                modified = true;
            }
            if (String.IsNullOrWhiteSpace(this.CopyTo) && !String.IsNullOrWhiteSpace(fromWish.CopyTo)) {
                this.CopyTo = fromWish.CopyTo;
                modified = true;
            }
            if (this.Version == null && fromWish.Version != null) {
                this.Version = fromWish.Version;
                modified = true;
            }
            if (this.Classifiers.Count == 0 && fromWish.Classifiers.Count > 0 ) {
                this.Classifiers = fromWish.Classifiers.Clone();
                modified = true;
            }
            if (String.IsNullOrWhiteSpace(this.Arch) && !String.IsNullOrWhiteSpace(fromWish.Arch)) {
                this.Arch = fromWish.Arch;
                modified = true;
            }
            if (String.IsNullOrWhiteSpace(this.Runtime) && !String.IsNullOrWhiteSpace(fromWish.Runtime)) {
                this.Runtime = fromWish.Runtime;
                modified = true;
            }

            if (fromWish.Scope > Scope) {
                this.Scope = fromWish.Scope;
                modified = true;
            }

            //TODO:also set sources on the merged lists
            this.TransitiveWishes = MergeLists(fromWish.TransitiveWishes, this.TransitiveWishes);

            if (modified) {
                SourceLocations.AddToSourceLocations(this, fromWish.Source);
            }
        }
Пример #12
0
 public bool FilterExistsFor(Wish wish)
 {
     var set = GetWishSetForOrNull(wish);
     return set != null && set.ContainsVersion(wish.Version) && set.HighestScope >= wish.Scope;
 }
Пример #13
0
 public NewProject TransitiveWish(Wish d)
 {
     base.TransitiveWishes.Add(d.Clone());
     return this;
 }
Пример #14
0
 public NewModule OptionalWishWith(Wish wish)
 {
     base.OptionalWishes.Add(wish);
     return this;
 }
Пример #15
0
 private ResolverWishSet GetWishSetForOrNull(Wish wish)
 {
     ResolverWishSet set;
     if(m_wishSetsByKey.TryGetValue(wish.Key, out set)){
         return set;
     }
     return null;
 }
Пример #16
0
        private List<Wish> PostProcess(List<Wish> wishes, Wish defaults, Scopes scope)
        {
            wishes = Wish.CloneAndFillInBlanksFrom(wishes, defaults);
            wishes.ForEach(w => {
                w.Scope = scope;
                if( w.Version==null ){
                    w.Version = VersionMatcher.AnyMatcher;
                }
                //TODO:recursive?
                SetChildTransitivies(w);
            });

            SourceLocations.AddToSourceLocations(wishes, Source);
            return wishes;
        }
Пример #17
0
 private void IncludeTransitivesOf(WishList addTo, int depth, Wish wish)
 {
     foreach (var child in wish.TransitiveWishes) {
         addTo.AddOrFailIfExists(child);
         IncludeTransitivesOf(addTo, depth + 1, child);
     }
 }
Пример #18
0
 private static void SetChildTransitivies(Wish wish)
 {
     foreach (var child in wish.TransitiveWishes) {
         child.Scope = Scopes.Transitive;
         SetChildTransitivies(child);
     }
 }
Пример #19
0
 /// <summary>
 /// Pick the next child line where one more dependency is picked and any resolution without picking another aribitrary version
 /// is also performed
 /// </summary>
 /// <returns>Pick the next line with atleast one wish resolved by picking some version. More wishes could be resolved due to this
 /// adding additional wishes for the picked version which causes other wishes to resolve to a fixed dep</returns>
 internal ResolverLine PickNextLine()
 {
     Log.Trace("PickNextLine");
     m_wishSets.PrintResolvedSoFar();
     m_wishSets.PrintNeedResolving();
     //TODO:introduce a strategy here to allow different pick strategies
     //pick a version of each requirement. Pick versions with the least amount of change first
     //a.k.a build incr first, then minor, then major
     foreach (var unfixed in m_wishSets.FindAllUnfixedWishSets().Where(w => !w.HasOnlyTransitive())) {
         Dependency fixedDep;
         do {
             var nextWishSetToBeFixed = m_wishSets.LocalWishSetFor(unfixed.FirstWish);
             Log.Debug("picking dep for wishes : " + nextWishSetToBeFixed.ToSummary());
             fixedDep = nextWishSetToBeFixed.PickNextFixedDependency();
             Log.Debug("picked dep : " + fixedDep.SafeToSummary());
             if (fixedDep == null) {
                 Log.Debug("no more options for : " + nextWishSetToBeFixed.SafeToSummary());
                 //no more deps to pick from, lets try to pick another wish to fix tos a set dependency
                 continue;
             }
             var nextLine = NewChildLine();
             var fixedWish = new Wish(fixedDep){Scope = unfixed.HighestScope};
             Log.Debug("fixing dep using wish : " + fixedWish.SafeToSummary());
             nextLine.AddWish(fixedWish);
             nextLine.ResolveWhatCanBe();
             if (nextLine.CanMatch()) {
                 Log.Debug("returning next line");
                 return nextLine;
             } else {
                 Log.Debug("Can't match next line, trying next new line");
             }
         } while( fixedDep != null );
     }
     Log.Trace("no next candidates, returning null");
     return null;
 }
Пример #20
0
 /// <summary>
 /// Add a wish unless there is already a matching constraint
 /// </summary>
 /// <returns>true if added, false if there was already a wish matching the same requirements</returns>
 internal bool AddWish(Wish wish)
 {
     return m_wishSets.AddWish(wish);
 }
Пример #21
0
 public ResolverWishSet LocalWishSetFor(Wish wish)
 {
     var key = wish.Key;
     //already added our filter
     if (m_localModifiedKeys.Contains(key)) {
         return m_wishSetsByKey[key];
     }
     m_localModifiedKeys.Add(key);
     ResolverWishSet existingWishes;
     if (m_wishSetsByKey.TryGetValue(key, out existingWishes)) { //if we already have a wishlist for this type then add another version constraint on to it
         var wrappingSet = new ResolverWishSet(wish, existingWishes);
         m_wishSetsByKey[key] = wrappingSet;
         Log.Trace("Wrapped existing wishset : " + existingWishes.ToSummary());
         return wrappingSet;
     } else { //a new key and therefore wishlist
         var newSet = new ResolverWishSet(wish, m_cache);
         m_wishSetsByKey[key] = newSet;
         Log.Trace("Added new wishset : " + newSet.ToSummary());
         return newSet;
     }
 }
Пример #22
0
 public NewSolution Wish(Wish wish)
 {
     base.Wishes.Add(wish.Clone());
     return this;
 }
Пример #23
0
 public Wish Clone()
 {
     var clone = new Wish();
     Clone(clone);
     clone.Version = Version;
     clone.Scope = Scope;
     clone.CopyTo = CopyTo;
     clone.TransitiveWishes = TransitiveWishes==null?new List<Wish>():new List<Wish>(TransitiveWishes);
     return clone;
 }
Пример #24
0
 public Wish CloneAndFillInBlanksFrom(Wish parent)
 {
     var clone = Clone();
     clone.InternalFillInBlanksFrom(parent);
     return clone;
 }
Пример #25
0
 public IList<Dependency> FindDependenciesMatching(Wish wish)
 {
     return m_cache.FindDependenciesMatching(wish);
 }
Пример #26
0
 public NewProject RuntimeWish(Wish d)
 {
     base.RuntimeWishes.Add(d.Clone());
     return this;
 }