SHARE
TWEET

Untitled

a guest Dec 16th, 2018 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. From 751b79c28a00ab4e8c8b0dd59cc4472fb0ac2a12 Mon Sep 17 00:00:00 2001
  2. From: Ciaran McCreesh <ciaran.mccreesh@googlemail.com>
  3. Date: Fri, 31 Aug 2012 21:12:57 +0100
  4. Subject: [PATCH] Fix || ( ) deps under a non-enabled label.
  5.  
  6. ---
  7.  paludis/resolver/resolver_TEST_any.cc       | 21 +++++++
  8.  paludis/resolver/resolver_TEST_any_setup.sh | 21 +++++++
  9.  paludis/resolver/sanitised_dependencies.cc  | 88 ++++++++++++++++++-----------
  10.  3 files changed, 96 insertions(+), 34 deletions(-)
  11.  
  12. diff --git a/paludis/resolver/resolver_TEST_any.cc b/paludis/resolver/resolver_TEST_any.cc
  13. index fa94ed9..2f276de 100644
  14. --- a/paludis/resolver/resolver_TEST_any.cc
  15. +++ b/paludis/resolver/resolver_TEST_any.cc
  16. @@ -344,3 +344,24 @@ TEST_F(ResolverAnyTestCase, UpgradeOverAny)
  17.              );
  18.  }
  19.  
  20. +TEST_F(ResolverAnyTestCase, NoActiveLabels)
  21. +{
  22. +    std::shared_ptr<const Resolved> resolved(data->get_resolved("no-active-labels/target"));
  23. +
  24. +    this->check_resolved(resolved,
  25. +            n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
  26. +                .change(QualifiedPackageName("no-active-labels/target"))
  27. +                .finished()),
  28. +            n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
  29. +                .finished()),
  30. +            n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
  31. +                .finished()),
  32. +            n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
  33. +                .finished()),
  34. +            n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
  35. +                .finished()),
  36. +            n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
  37. +                .finished())
  38. +            );
  39. +}
  40. +
  41. diff --git a/paludis/resolver/resolver_TEST_any_setup.sh b/paludis/resolver/resolver_TEST_any_setup.sh
  42. index 5630934..92bfb12 100755
  43. --- a/paludis/resolver/resolver_TEST_any_setup.sh
  44. +++ b/paludis/resolver/resolver_TEST_any_setup.sh
  45. @@ -176,5 +176,26 @@ SLOT="0"
  46.  DEPENDENCIES=""
  47.  END
  48.  
  49. +# no-active-labels
  50. +echo 'no-active-labels' >> metadata/categories.conf
  51. +
  52. +mkdir -p 'packages/no-active-labels/target'
  53. +cat <<END > packages/no-active-labels/target/target-1.exheres-0
  54. +SUMMARY="target"
  55. +PLATFORMS="test"
  56. +SLOT="0"
  57. +DEPENDENCIES="
  58. +    test-expensive: || ( no-active-labels/dep no-active-labels/dep )
  59. +    "
  60. +END
  61. +
  62. +mkdir -p 'packages/no-active-labels/dep'
  63. +cat <<END > packages/no-active-labels/dep/dep-1.exheres-0
  64. +SUMMARY="dep"
  65. +PLATFORMS="test"
  66. +SLOT="0"
  67. +DEPENDENCIES=""
  68. +END
  69. +
  70.  cd ..
  71.  
  72. diff --git a/paludis/resolver/sanitised_dependencies.cc b/paludis/resolver/sanitised_dependencies.cc
  73. index 4c8b1ad..8012fe4 100644
  74. --- a/paludis/resolver/sanitised_dependencies.cc
  75. +++ b/paludis/resolver/sanitised_dependencies.cc
  76. @@ -117,7 +117,7 @@ namespace
  77.          const std::shared_ptr<const Resolution> our_resolution;
  78.          const std::shared_ptr<const PackageID> our_id;
  79.          const std::shared_ptr<const ChangedChoices> changed_choices;
  80. -        const std::function<SanitisedDependency (const PackageOrBlockDepSpec &)> parent_make_sanitised;
  81. +        const std::function<std::shared_ptr<SanitisedDependency> (const PackageOrBlockDepSpec &)> parent_make_sanitised;
  82.  
  83.          bool super_complicated, nested;
  84.  
  85. @@ -131,7 +131,7 @@ namespace
  86.                  const Decider & r, const std::shared_ptr<const Resolution> & q,
  87.                  const std::shared_ptr<const PackageID> & o,
  88.                  const std::shared_ptr<const ChangedChoices> & c,
  89. -                const std::function<SanitisedDependency (const PackageOrBlockDepSpec &)> & f) :
  90. +                const std::function<std::shared_ptr<SanitisedDependency> (const PackageOrBlockDepSpec &)> & f) :
  91.              env(e),
  92.              decider(r),
  93.              our_resolution(q),
  94. @@ -253,7 +253,7 @@ namespace
  95.          }
  96.  
  97.          void commit(
  98. -                const std::function<SanitisedDependency (const PackageOrBlockDepSpec &)> & make_sanitised,
  99. +                const std::function<std::shared_ptr<SanitisedDependency> (const PackageOrBlockDepSpec &)> & maybe_make_sanitised,
  100.                  const std::function<void (const SanitisedDependency &)> & apply)
  101.          {
  102.              if (! seen_any)
  103. @@ -278,12 +278,16 @@ namespace
  104.                      for (std::list<PackageOrBlockDepSpec>::const_iterator h(g->begin()), h_end(g->end()) ;
  105.                              h != h_end ; ++h)
  106.                      {
  107. -                        auto score(decider.find_any_score(our_resolution, our_id, make_sanitised(PackageOrBlockDepSpec(*h))));
  108. -                        Log::get_instance()->message("resolver.sanitised_dependencies.any_score", ll_debug, lc_context)
  109. -                            << "Scored " << *h << " as " << score.first << " " << score.second;
  110. -
  111. -                        if (score < worst_score)
  112. -                            worst_score = score;
  113. +                        auto s(maybe_make_sanitised(PackageOrBlockDepSpec(*h)));
  114. +                        if (s)
  115. +                        {
  116. +                            auto score(decider.find_any_score(our_resolution, our_id, *s));
  117. +                            Log::get_instance()->message("resolver.sanitised_dependencies.any_score", ll_debug, lc_context)
  118. +                                << "Scored " << *h << " as " << score.first << " " << score.second;
  119. +
  120. +                            if (score < worst_score)
  121. +                                worst_score = score;
  122. +                        }
  123.                      }
  124.  
  125.                      if (worst_score > best_score)
  126. @@ -293,11 +297,17 @@ namespace
  127.                      }
  128.                  }
  129.  
  130. -                if (g_best == child_groups.end())
  131. -                    throw InternalError(PALUDIS_HERE, "why did that happen?");
  132. -                for (std::list<PackageOrBlockDepSpec>::const_iterator h(g_best->begin()), h_end(g_best->end()) ;
  133. -                        h != h_end ; ++h)
  134. -                    apply(make_sanitised(*h));
  135. +                if (g_best != child_groups.end())
  136. +                {
  137. +                    /* might be nothing to do, if no labels are enabled */
  138. +                    for (std::list<PackageOrBlockDepSpec>::const_iterator h(g_best->begin()), h_end(g_best->end()) ;
  139. +                            h != h_end ; ++h)
  140. +                    {
  141. +                        auto s(maybe_make_sanitised(*h));
  142. +                        if (s)
  143. +                            apply(*s);
  144. +                    }
  145. +                }
  146.              }
  147.          }
  148.      };
  149. @@ -346,7 +356,7 @@ namespace
  150.              sanitised_dependencies.add(dep);
  151.          }
  152.  
  153. -        SanitisedDependency make_sanitised(const PackageOrBlockDepSpec & spec)
  154. +        std::shared_ptr<SanitisedDependency> maybe_make_sanitised(const PackageOrBlockDepSpec & spec)
  155.          {
  156.              std::stringstream adl, acs;
  157.              auto classifier_builder(std::make_shared<LabelsClassifierBuilder>(env, our_id));
  158. @@ -358,31 +368,41 @@ namespace
  159.                  (*i)->accept(*classifier_builder);
  160.              }
  161.  
  162. -            for (auto c(conditions_stack.begin()), c_end(conditions_stack.end()) ;
  163. -                    c != c_end ; ++c)
  164. -                acs << (acs.str().empty() ? "" : ", ") << stringify(*c);
  165. -
  166. -            return make_named_values<SanitisedDependency>(
  167. -                    n::active_conditions_as_string() = acs.str(),
  168. -                    n::active_dependency_labels() = *labels_stack.begin(),
  169. -                    n::active_dependency_labels_as_string() = adl.str(),
  170. -                    n::active_dependency_labels_classifier() = classifier_builder->create(),
  171. -                    n::from_id() = our_id,
  172. -                    n::metadata_key_human_name() = human_name,
  173. -                    n::metadata_key_raw_name() = raw_name,
  174. -                    n::original_specs_as_string() = original_specs_as_string,
  175. -                    n::spec() = spec
  176. -                    );
  177. +            auto classifier(classifier_builder->create());
  178. +            if (classifier->any_enabled)
  179. +            {
  180. +                for (auto c(conditions_stack.begin()), c_end(conditions_stack.end()) ;
  181. +                        c != c_end ; ++c)
  182. +                    acs << (acs.str().empty() ? "" : ", ") << stringify(*c);
  183. +
  184. +                return make_shared_copy(make_named_values<SanitisedDependency>(
  185. +                            n::active_conditions_as_string() = acs.str(),
  186. +                            n::active_dependency_labels() = *labels_stack.begin(),
  187. +                            n::active_dependency_labels_as_string() = adl.str(),
  188. +                            n::active_dependency_labels_classifier() = classifier,
  189. +                            n::from_id() = our_id,
  190. +                            n::metadata_key_human_name() = human_name,
  191. +                            n::metadata_key_raw_name() = raw_name,
  192. +                            n::original_specs_as_string() = original_specs_as_string,
  193. +                            n::spec() = spec
  194. +                            ));
  195. +            }
  196. +            else
  197. +                return make_null_shared_ptr();
  198.          }
  199.  
  200.          void visit(const DependencySpecTree::NodeType<PackageDepSpec>::Type & node)
  201.          {
  202. -            add(make_sanitised(*node.spec()));
  203. +            auto s(maybe_make_sanitised(*node.spec()));
  204. +            if (s)
  205. +                add(*s);
  206.          }
  207.  
  208.          void visit(const DependencySpecTree::NodeType<BlockDepSpec>::Type & node)
  209.          {
  210. -            add(make_sanitised(*node.spec()));
  211. +            auto s(maybe_make_sanitised(*node.spec()));
  212. +            if (s)
  213. +                add(*s);
  214.          }
  215.  
  216.          void visit(const DependencySpecTree::NodeType<ConditionalDepSpec>::Type & node)
  217. @@ -415,10 +435,10 @@ namespace
  218.              }
  219.  
  220.              AnyDepSpecChildHandler h(env, decider, our_resolution, our_id, changed_choices,
  221. -                    std::bind(&Finder::make_sanitised, this, std::placeholders::_1));
  222. +                    std::bind(&Finder::maybe_make_sanitised, this, std::placeholders::_1));
  223.              std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(h));
  224.              h.commit(
  225. -                    std::bind(&Finder::make_sanitised, this, std::placeholders::_1),
  226. +                    std::bind(&Finder::maybe_make_sanitised, this, std::placeholders::_1),
  227.                      std::bind(&Finder::add, this, std::placeholders::_1)
  228.                      );
  229.          }
  230. --
  231. 1.7.12
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top