aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-20 13:49:50 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-20 13:49:50 +0100
commitc07c3cfc75fa8a79b1bcb89ea04b976820052c93 (patch)
tree3bf77a8462f1711fd830b89f1b89d2f1b1d3a05a
parent1dba750da1bc0e4c3c15a08a9515e8093fe9bfa4 (diff)
downloadpaludis-c07c3cfc75fa8a79b1bcb89ea04b976820052c93.tar.gz
paludis-c07c3cfc75fa8a79b1bcb89ea04b976820052c93.tar.xz
Serialise unique specs rather than IDs
Fixes: ticket:887
-rw-r--r--paludis/resolver/job.cc127
-rw-r--r--paludis/resolver/job.hh22
-rw-r--r--paludis/resolver/orderer.cc22
-rw-r--r--src/clients/cave/cmd_execute_resolution.cc131
4 files changed, 195 insertions, 107 deletions
diff --git a/paludis/resolver/job.cc b/paludis/resolver/job.cc
index 7bf5791..f2bdf58 100644
--- a/paludis/resolver/job.cc
+++ b/paludis/resolver/job.cc
@@ -22,10 +22,13 @@
#include <paludis/resolver/job_state.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/make_shared_ptr.hh>
-#include <paludis/util/sequence.hh>
+#include <paludis/util/sequence-impl.hh>
+#include <paludis/util/wrapped_forward_iterator-impl.hh>
#include <paludis/serialise-impl.hh>
#include <paludis/package_id.hh>
#include <paludis/name.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/user_dep_spec.hh>
using namespace paludis;
using namespace paludis::resolver;
@@ -35,16 +38,16 @@ namespace paludis
template <>
struct Implementation<PretendJob>
{
- const std::tr1::shared_ptr<const PackageID> origin_id;
+ const PackageDepSpec origin_id_spec;
- Implementation(const std::tr1::shared_ptr<const PackageID> & o) :
- origin_id(o)
+ Implementation(const PackageDepSpec & o) :
+ origin_id_spec(o)
{
}
};
}
-PretendJob::PretendJob(const std::tr1::shared_ptr<const PackageID> & o) :
+PretendJob::PretendJob(const PackageDepSpec & o) :
PrivateImplementationPattern<PretendJob>(new Implementation<PretendJob>(o))
{
}
@@ -53,10 +56,10 @@ PretendJob::~PretendJob()
{
}
-const std::tr1::shared_ptr<const PackageID>
-PretendJob::origin_id() const
+const PackageDepSpec
+PretendJob::origin_id_spec() const
{
- return _imp->origin_id;
+ return _imp->origin_id_spec;
}
const std::tr1::shared_ptr<PretendJob>
@@ -64,7 +67,8 @@ PretendJob::deserialise(Deserialisation & d)
{
Deserialisator v(d, "PretendJob");
return make_shared_ptr(new PretendJob(
- v.member<std::tr1::shared_ptr<const PackageID> >("origin_id")
+ parse_user_package_dep_spec(v.member<std::string>("origin_id_spec"),
+ d.deserialiser().environment(), UserPackageDepSpecOptions() + updso_no_disambiguation)
));
}
@@ -72,7 +76,7 @@ void
PretendJob::serialise(Serialiser & s) const
{
s.object("PretendJob")
- .member(SerialiserFlags<serialise::might_be_null>(), "origin_id", origin_id())
+ .member(SerialiserFlags<>(), "origin_id_spec", stringify(origin_id_spec()))
;
}
@@ -99,14 +103,14 @@ namespace paludis
struct Implementation<FetchJob>
{
const std::tr1::shared_ptr<const JobRequirements> requirements;
- const std::tr1::shared_ptr<const PackageID> origin_id;
+ const PackageDepSpec origin_id_spec;
std::tr1::shared_ptr<JobState> state;
Implementation(
const std::tr1::shared_ptr<const JobRequirements> & r,
- const std::tr1::shared_ptr<const PackageID> & o) :
+ const PackageDepSpec & o) :
requirements(r),
- origin_id(o)
+ origin_id_spec(o)
{
}
};
@@ -114,7 +118,7 @@ namespace paludis
FetchJob::FetchJob(
const std::tr1::shared_ptr<const JobRequirements> & r,
- const std::tr1::shared_ptr<const PackageID> & o) :
+ const PackageDepSpec & o) :
PrivateImplementationPattern<FetchJob>(new Implementation<FetchJob>(r, o))
{
}
@@ -123,10 +127,10 @@ FetchJob::~FetchJob()
{
}
-const std::tr1::shared_ptr<const PackageID>
-FetchJob::origin_id() const
+const PackageDepSpec
+FetchJob::origin_id_spec() const
{
- return _imp->origin_id;
+ return _imp->origin_id_spec;
}
const std::tr1::shared_ptr<JobState>
@@ -161,7 +165,8 @@ FetchJob::deserialise(Deserialisation & d)
std::tr1::shared_ptr<FetchJob> result(new FetchJob(
requirements,
- v.member<std::tr1::shared_ptr<const PackageID> >("origin_id")
+ parse_user_package_dep_spec(v.member<std::string>("origin_id_spec"),
+ d.deserialiser().environment(), UserPackageDepSpecOptions() + updso_no_disambiguation)
));
result->set_state(v.member<std::tr1::shared_ptr<JobState> >("state"));
return result;
@@ -172,7 +177,7 @@ FetchJob::serialise(Serialiser & s) const
{
s.object("FetchJob")
.member(SerialiserFlags<serialise::container, serialise::might_be_null>(), "requirements", requirements())
- .member(SerialiserFlags<serialise::might_be_null>(), "origin_id", origin_id())
+ .member(SerialiserFlags<>(), "origin_id_spec", stringify(origin_id_spec()))
.member(SerialiserFlags<serialise::might_be_null>(), "state", state())
;
}
@@ -183,25 +188,25 @@ namespace paludis
struct Implementation<InstallJob>
{
const std::tr1::shared_ptr<const JobRequirements> requirements;
- const std::tr1::shared_ptr<const PackageID> origin_id;
+ const PackageDepSpec origin_id_spec;
const RepositoryName destination_repository_name;
const DestinationType destination_type;
- const std::tr1::shared_ptr<const PackageIDSequence> replacing;
+ const std::tr1::shared_ptr<const Sequence<PackageDepSpec> > replacing_specs;
std::tr1::shared_ptr<JobState> state;
Implementation(
const std::tr1::shared_ptr<const JobRequirements> & q,
- const std::tr1::shared_ptr<const PackageID> & o,
+ const PackageDepSpec & o,
const RepositoryName & d,
const DestinationType t,
- const std::tr1::shared_ptr<const PackageIDSequence> & r
+ const std::tr1::shared_ptr<const Sequence<PackageDepSpec> > & r
) :
requirements(q),
- origin_id(o),
+ origin_id_spec(o),
destination_repository_name(d),
destination_type(t),
- replacing(r)
+ replacing_specs(r)
{
}
};
@@ -209,10 +214,10 @@ namespace paludis
InstallJob::InstallJob(
const std::tr1::shared_ptr<const JobRequirements> & q,
- const std::tr1::shared_ptr<const PackageID> & o,
+ const PackageDepSpec & o,
const RepositoryName & d,
const DestinationType t,
- const std::tr1::shared_ptr<const PackageIDSequence> & r
+ const std::tr1::shared_ptr<const Sequence<PackageDepSpec> > & r
) :
PrivateImplementationPattern<InstallJob>(new Implementation<InstallJob>(q, o, d, t, r))
{
@@ -222,10 +227,10 @@ InstallJob::~InstallJob()
{
}
-const std::tr1::shared_ptr<const PackageID>
-InstallJob::origin_id() const
+const PackageDepSpec
+InstallJob::origin_id_spec() const
{
- return _imp->origin_id;
+ return _imp->origin_id_spec;
}
const RepositoryName
@@ -240,10 +245,10 @@ InstallJob::destination_type() const
return _imp->destination_type;
}
-const std::tr1::shared_ptr<const PackageIDSequence>
-InstallJob::replacing() const
+const std::tr1::shared_ptr<const Sequence<PackageDepSpec> >
+InstallJob::replacing_specs() const
{
- return _imp->replacing;
+ return _imp->replacing_specs;
}
const std::tr1::shared_ptr<JobState>
@@ -269,11 +274,12 @@ InstallJob::deserialise(Deserialisation & d)
{
Deserialisator v(d, "InstallJob");
- std::tr1::shared_ptr<PackageIDSequence> replacing(new PackageIDSequence);
+ std::tr1::shared_ptr<Sequence<PackageDepSpec> > replacing_specs(new Sequence<PackageDepSpec>);
{
- Deserialisator vv(*v.find_remove_member("replacing"), "c");
+ Deserialisator vv(*v.find_remove_member("replacing_specs"), "c");
for (int n(1), n_end(vv.member<int>("count") + 1) ; n != n_end ; ++n)
- replacing->push_back(vv.member<std::tr1::shared_ptr<const PackageID> >(stringify(n)));
+ replacing_specs->push_back(parse_user_package_dep_spec(vv.member<std::string>(stringify(n)),
+ d.deserialiser().environment(), UserPackageDepSpecOptions() + updso_no_disambiguation));
}
std::tr1::shared_ptr<JobRequirements> requirements(new JobRequirements);
@@ -285,10 +291,11 @@ InstallJob::deserialise(Deserialisation & d)
std::tr1::shared_ptr<InstallJob> result(new InstallJob(
requirements,
- v.member<std::tr1::shared_ptr<const PackageID> >("origin_id"),
+ parse_user_package_dep_spec(v.member<std::string>("origin_id_spec"),
+ d.deserialiser().environment(), UserPackageDepSpecOptions() + updso_no_disambiguation),
RepositoryName(v.member<std::string>("destination_repository_name")),
destringify<DestinationType>(v.member<std::string>("destination_type")),
- replacing
+ replacing_specs
));
result->set_state(v.member<std::tr1::shared_ptr<JobState> >("state"));
@@ -298,12 +305,18 @@ InstallJob::deserialise(Deserialisation & d)
void
InstallJob::serialise(Serialiser & s) const
{
+ std::tr1::shared_ptr<Sequence<std::string> > replacing_specs_s(new Sequence<std::string>);
+ for (Sequence<PackageDepSpec>::ConstIterator r(replacing_specs()->begin()),
+ r_end(replacing_specs()->end()) ;
+ r != r_end ; ++r)
+ replacing_specs_s->push_back(stringify(*r));
+
s.object("InstallJob")
.member(SerialiserFlags<serialise::container, serialise::might_be_null>(), "requirements", requirements())
- .member(SerialiserFlags<serialise::might_be_null>(), "origin_id", origin_id())
+ .member(SerialiserFlags<>(), "origin_id_spec", stringify(origin_id_spec()))
.member(SerialiserFlags<>(), "destination_repository_name", stringify(destination_repository_name()))
.member(SerialiserFlags<>(), "destination_type", stringify(destination_type()))
- .member(SerialiserFlags<serialise::container, serialise::might_be_null>(), "replacing", replacing())
+ .member(SerialiserFlags<serialise::container, serialise::might_be_null>(), "replacing_specs", replacing_specs_s)
.member(SerialiserFlags<serialise::might_be_null>(), "state", state())
;
}
@@ -314,16 +327,16 @@ namespace paludis
struct Implementation<UninstallJob>
{
const std::tr1::shared_ptr<const JobRequirements> requirements;
- const std::tr1::shared_ptr<const PackageIDSequence> ids_to_remove;
+ const std::tr1::shared_ptr<const Sequence<PackageDepSpec> > ids_to_remove_specs;
std::tr1::shared_ptr<JobState> state;
Implementation(
const std::tr1::shared_ptr<const JobRequirements> & q,
- const std::tr1::shared_ptr<const PackageIDSequence> & r
+ const std::tr1::shared_ptr<const Sequence<PackageDepSpec> > & r
) :
requirements(q),
- ids_to_remove(r)
+ ids_to_remove_specs(r)
{
}
};
@@ -331,7 +344,7 @@ namespace paludis
UninstallJob::UninstallJob(
const std::tr1::shared_ptr<const JobRequirements> & q,
- const std::tr1::shared_ptr<const PackageIDSequence> & r
+ const std::tr1::shared_ptr<const Sequence<PackageDepSpec> > & r
) :
PrivateImplementationPattern<UninstallJob>(new Implementation<UninstallJob>(q, r))
{
@@ -341,10 +354,10 @@ UninstallJob::~UninstallJob()
{
}
-const std::tr1::shared_ptr<const PackageIDSequence>
-UninstallJob::ids_to_remove() const
+const std::tr1::shared_ptr<const Sequence<PackageDepSpec> >
+UninstallJob::ids_to_remove_specs() const
{
- return _imp->ids_to_remove;
+ return _imp->ids_to_remove_specs;
}
const std::tr1::shared_ptr<JobState>
@@ -370,11 +383,12 @@ UninstallJob::deserialise(Deserialisation & d)
{
Deserialisator v(d, "UninstallJob");
- std::tr1::shared_ptr<PackageIDSequence> ids_to_remove(new PackageIDSequence);
+ std::tr1::shared_ptr<Sequence<PackageDepSpec> > ids_to_remove_specs(new Sequence<PackageDepSpec> );
{
- Deserialisator vv(*v.find_remove_member("ids_to_remove"), "c");
+ Deserialisator vv(*v.find_remove_member("ids_to_remove_specs"), "c");
for (int n(1), n_end(vv.member<int>("count") + 1) ; n != n_end ; ++n)
- ids_to_remove->push_back(vv.member<std::tr1::shared_ptr<const PackageID> >(stringify(n)));
+ ids_to_remove_specs->push_back(parse_user_package_dep_spec(vv.member<std::string>(stringify(n)),
+ d.deserialiser().environment(), UserPackageDepSpecOptions() + updso_no_disambiguation));
}
std::tr1::shared_ptr<JobRequirements> requirements(new JobRequirements);
@@ -386,7 +400,7 @@ UninstallJob::deserialise(Deserialisation & d)
std::tr1::shared_ptr<UninstallJob> result(new UninstallJob(
requirements,
- ids_to_remove
+ ids_to_remove_specs
));
result->set_state(v.member<std::tr1::shared_ptr<JobState> >("state"));
@@ -396,10 +410,19 @@ UninstallJob::deserialise(Deserialisation & d)
void
UninstallJob::serialise(Serialiser & s) const
{
+ std::tr1::shared_ptr<Sequence<std::string> > ids_to_remove_specs_s(new Sequence<std::string>);
+ for (Sequence<PackageDepSpec>::ConstIterator r(ids_to_remove_specs()->begin()),
+ r_end(ids_to_remove_specs()->end()) ;
+ r != r_end ; ++r)
+ ids_to_remove_specs_s->push_back(stringify(*r));
+
s.object("UninstallJob")
.member(SerialiserFlags<serialise::container, serialise::might_be_null>(), "requirements", requirements())
- .member(SerialiserFlags<serialise::container, serialise::might_be_null>(), "ids_to_remove", ids_to_remove())
+ .member(SerialiserFlags<serialise::container, serialise::might_be_null>(), "ids_to_remove_specs", ids_to_remove_specs_s)
.member(SerialiserFlags<serialise::might_be_null>(), "state", state())
;
}
+template class Sequence<PackageDepSpec>;
+template class WrappedForwardIterator<Sequence<PackageDepSpec>::ConstIteratorTag, const PackageDepSpec>;
+
diff --git a/paludis/resolver/job.hh b/paludis/resolver/job.hh
index a27bc17..a6e081a 100644
--- a/paludis/resolver/job.hh
+++ b/paludis/resolver/job.hh
@@ -27,7 +27,7 @@
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/simple_visitor.hh>
#include <paludis/util/type_list.hh>
-#include <paludis/package_id-fwd.hh>
+#include <paludis/dep_spec-fwd.hh>
#include <paludis/serialise-fwd.hh>
#include <paludis/name-fwd.hh>
#include <tr1/memory>
@@ -41,11 +41,11 @@ namespace paludis
{
public:
PretendJob(
- const std::tr1::shared_ptr<const PackageID> &
+ const PackageDepSpec &
);
~PretendJob();
- const std::tr1::shared_ptr<const PackageID> origin_id() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ const PackageDepSpec origin_id_spec() const PALUDIS_ATTRIBUTE((warn_unused_result));
static const std::tr1::shared_ptr<PretendJob> deserialise(Deserialisation &) PALUDIS_ATTRIBUTE((warn_unused_result));
void serialise(Serialiser &) const;
@@ -75,11 +75,11 @@ namespace paludis
public:
FetchJob(
const std::tr1::shared_ptr<const JobRequirements> &,
- const std::tr1::shared_ptr<const PackageID> &
+ const PackageDepSpec &
);
~FetchJob();
- const std::tr1::shared_ptr<const PackageID> origin_id() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ const PackageDepSpec origin_id_spec() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual const std::tr1::shared_ptr<JobState> state() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual void set_state(const std::tr1::shared_ptr<JobState> &);
@@ -98,16 +98,16 @@ namespace paludis
public:
InstallJob(
const std::tr1::shared_ptr<const JobRequirements> &,
- const std::tr1::shared_ptr<const PackageID> &,
+ const PackageDepSpec &,
const RepositoryName &,
const DestinationType,
- const std::tr1::shared_ptr<const PackageIDSequence> &);
+ const std::tr1::shared_ptr<const Sequence<PackageDepSpec> > &);
~InstallJob();
- const std::tr1::shared_ptr<const PackageID> origin_id() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ const PackageDepSpec origin_id_spec() const PALUDIS_ATTRIBUTE((warn_unused_result));
const RepositoryName destination_repository_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
DestinationType destination_type() const PALUDIS_ATTRIBUTE((warn_unused_result));
- const std::tr1::shared_ptr<const PackageIDSequence> replacing() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ const std::tr1::shared_ptr<const Sequence<PackageDepSpec> > replacing_specs() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual const std::tr1::shared_ptr<JobState> state() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual void set_state(const std::tr1::shared_ptr<JobState> &);
@@ -126,11 +126,11 @@ namespace paludis
public:
UninstallJob(
const std::tr1::shared_ptr<const JobRequirements> &,
- const std::tr1::shared_ptr<const PackageIDSequence> &
+ const std::tr1::shared_ptr<const Sequence<PackageDepSpec> > &
);
~UninstallJob();
- const std::tr1::shared_ptr<const PackageIDSequence> ids_to_remove() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ const std::tr1::shared_ptr<const Sequence<PackageDepSpec> > ids_to_remove_specs() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual const std::tr1::shared_ptr<JobState> state() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual void set_state(const std::tr1::shared_ptr<JobState> &);
diff --git a/paludis/resolver/orderer.cc b/paludis/resolver/orderer.cc
index a4cfa42..f384ddb 100644
--- a/paludis/resolver/orderer.cc
+++ b/paludis/resolver/orderer.cc
@@ -621,11 +621,11 @@ namespace
void visit(const ChangesToMakeDecision & changes_to_make_decision) const
{
resolved->job_lists()->pretend_job_list()->append(make_shared_ptr(new PretendJob(
- changes_to_make_decision.origin_id())));
+ changes_to_make_decision.origin_id()->uniquely_identifying_spec())));
JobNumber fetch_job_n(resolved->job_lists()->execute_job_list()->append(make_shared_ptr(new FetchJob(
make_shared_ptr(new JobRequirements),
- changes_to_make_decision.origin_id()))));
+ changes_to_make_decision.origin_id()->uniquely_identifying_spec()))));
const std::tr1::shared_ptr<JobRequirements> requirements(new JobRequirements);
requirements->push_back(make_named_values<JobRequirement>(
@@ -643,12 +643,18 @@ namespace
recursed
);
+ const std::tr1::shared_ptr<Sequence<PackageDepSpec> > replacing(new Sequence<PackageDepSpec>);
+ for (PackageIDSequence::ConstIterator i(changes_to_make_decision.destination()->replacing()->begin()),
+ i_end(changes_to_make_decision.destination()->replacing()->end()) ;
+ i != i_end ; ++i)
+ replacing->push_back((*i)->uniquely_identifying_spec());
+
JobNumber install_job_n(resolved->job_lists()->execute_job_list()->append(make_shared_ptr(new InstallJob(
requirements,
- changes_to_make_decision.origin_id(),
+ changes_to_make_decision.origin_id()->uniquely_identifying_spec(),
changes_to_make_decision.destination()->repository(),
changes_to_make_decision.resolvent().destination_type(),
- changes_to_make_decision.destination()->replacing()
+ replacing
))));
install_job_numbers.insert(std::make_pair(resolvent, install_job_n));
@@ -656,9 +662,15 @@ namespace
void visit(const RemoveDecision & remove_decision) const
{
+ const std::tr1::shared_ptr<Sequence<PackageDepSpec> > removing(new Sequence<PackageDepSpec>);
+ for (PackageIDSequence::ConstIterator i(remove_decision.ids()->begin()),
+ i_end(remove_decision.ids()->end()) ;
+ i != i_end ; ++i)
+ removing->push_back((*i)->uniquely_identifying_spec());
+
resolved->job_lists()->execute_job_list()->append(make_shared_ptr(new UninstallJob(
make_shared_ptr(new JobRequirements),
- remove_decision.ids()
+ removing
)));
}
};
diff --git a/src/clients/cave/cmd_execute_resolution.cc b/src/clients/cave/cmd_execute_resolution.cc
index c6c0de9..4d2f118 100644
--- a/src/clients/cave/cmd_execute_resolution.cc
+++ b/src/clients/cave/cmd_execute_resolution.cc
@@ -70,6 +70,10 @@
#include <paludis/package_dep_spec_properties.hh>
#include <paludis/serialise.hh>
#include <paludis/ipc_output_manager.hh>
+#include <paludis/generator.hh>
+#include <paludis/selection.hh>
+#include <paludis/filtered_generator.hh>
+#include <paludis/filter.hh>
#include <set>
#include <iterator>
@@ -131,11 +135,14 @@ namespace
bool do_pretend(
const std::tr1::shared_ptr<Environment> & env,
const ExecuteResolutionCommandLine & cmdline,
- const std::tr1::shared_ptr<const PackageID> & origin_id,
+ const PackageDepSpec & origin_id_spec,
const int x, const int y, const int prev_x,
std::tr1::shared_ptr<OutputManager> & output_manager_goes_here)
{
- Context context("When pretending for '" + stringify(*origin_id) + "':");
+ Context context("When pretending for '" + stringify(origin_id_spec) + "':");
+
+ const std::tr1::shared_ptr<const PackageID> origin_id(*(*env)[selection::RequireExactlyOne(
+ generator::Matches(origin_id_spec, MatchPackageOptions()))]->begin());
if (0 != prev_x)
cout << std::string(stringify(prev_x).length() + stringify(y).length() + 4, '\010');
@@ -225,11 +232,14 @@ namespace
bool do_fetch(
const std::tr1::shared_ptr<Environment> & env,
const ExecuteResolutionCommandLine & cmdline,
- const std::tr1::shared_ptr<const PackageID> & id,
+ const PackageDepSpec & id_spec,
const int x, const int y, bool normal_only,
JobActiveState & active_state)
{
- Context context("When fetching for '" + stringify(*id) + "':");
+ Context context("When fetching for '" + stringify(id_spec) + "':");
+
+ const std::tr1::shared_ptr<const PackageID> id(*(*env)[selection::RequireExactlyOne(
+ generator::Matches(id_spec, MatchPackageOptions()))]->begin());
starting_action("fetch (" + std::string(normal_only ? "regular parts" : "extra parts") + ")", id, x, y);
@@ -301,13 +311,16 @@ namespace
bool do_install(
const std::tr1::shared_ptr<Environment> & env,
const ExecuteResolutionCommandLine & cmdline,
- const std::tr1::shared_ptr<const PackageID> & id,
+ const PackageDepSpec & id_spec,
const RepositoryName & destination_repository_name,
- const std::tr1::shared_ptr<const PackageIDSequence> & replacing,
+ const std::tr1::shared_ptr<const Sequence<PackageDepSpec> > & replacing_specs,
const DestinationType & destination_type,
const int x, const int y,
JobActiveState & active_state)
{
+ const std::tr1::shared_ptr<const PackageID> id(*(*env)[selection::RequireExactlyOne(
+ generator::Matches(id_spec, MatchPackageOptions()))]->begin());
+
std::string destination_string, action_string;
switch (destination_type)
{
@@ -339,10 +352,10 @@ namespace
command.append(" install --hooks --managed-output ");
command.append(stringify(id->uniquely_identifying_spec()));
command.append(" --destination " + stringify(destination_repository_name));
- for (PackageIDSequence::ConstIterator i(replacing->begin()),
- i_end(replacing->end()) ;
+ for (Sequence<PackageDepSpec>::ConstIterator i(replacing_specs->begin()),
+ i_end(replacing_specs->end()) ;
i != i_end ; ++i)
- command.append(" --replacing " + stringify((*i)->uniquely_identifying_spec()));
+ command.append(" --replacing " + stringify(*i));
command.append(" --x-of-y '" + stringify(x) + " of " + stringify(y) + "'");
@@ -403,11 +416,14 @@ namespace
bool do_uninstall(
const std::tr1::shared_ptr<Environment> & env,
const ExecuteResolutionCommandLine & cmdline,
- const std::tr1::shared_ptr<const PackageID> & id,
+ const PackageDepSpec & id_spec,
const int x, const int y,
JobActiveState & active_state)
{
- Context context("When removing '" + stringify(*id) + "':");
+ Context context("When removing '" + stringify(id_spec) + "':");
+
+ const std::tr1::shared_ptr<const PackageID> id(*(*env)[selection::RequireExactlyOne(
+ generator::Matches(id_spec, MatchPackageOptions()))]->begin());
starting_action("remove", id, x, y);
@@ -607,7 +623,7 @@ namespace
cout << "Executing pretend actions: " << std::flush;
std::tr1::shared_ptr<OutputManager> output_manager_goes_here;
- failed = failed || ! do_pretend(env, cmdline, (*c)->origin_id(), x, y, prev_x, output_manager_goes_here);
+ failed = failed || ! do_pretend(env, cmdline, (*c)->origin_id_spec(), x, y, prev_x, output_manager_goes_here);
prev_x = x;
}
@@ -673,14 +689,14 @@ namespace
const std::tr1::shared_ptr<JobActiveState> active_state(new JobActiveState);
install_item.set_state(active_state);
- if (! do_fetch(env, cmdline, install_item.origin_id(), counts.x_installs, counts.y_installs, false, *active_state))
+ if (! do_fetch(env, cmdline, install_item.origin_id_spec(), counts.x_installs, counts.y_installs, false, *active_state))
{
install_item.set_state(active_state->failed());
return 1;
}
- if (! do_install(env, cmdline, install_item.origin_id(), install_item.destination_repository_name(),
- install_item.replacing(), install_item.destination_type(),
+ if (! do_install(env, cmdline, install_item.origin_id_spec(), install_item.destination_repository_name(),
+ install_item.replacing_specs(), install_item.destination_type(),
counts.x_installs, counts.y_installs, *active_state))
{
install_item.set_state(active_state->failed());
@@ -698,8 +714,8 @@ namespace
const std::tr1::shared_ptr<JobActiveState> active_state(new JobActiveState);
uninstall_item.set_state(active_state);
- for (PackageIDSequence::ConstIterator i(uninstall_item.ids_to_remove()->begin()),
- i_end(uninstall_item.ids_to_remove()->end()) ;
+ for (Sequence<PackageDepSpec>::ConstIterator i(uninstall_item.ids_to_remove_specs()->begin()),
+ i_end(uninstall_item.ids_to_remove_specs()->end()) ;
i != i_end ; ++i)
if (! do_uninstall(env, cmdline, *i, counts.x_installs, counts.y_installs, *active_state))
{
@@ -718,7 +734,7 @@ namespace
const std::tr1::shared_ptr<JobActiveState> active_state(new JobActiveState);
fetch_item.set_state(active_state);
- if (! do_fetch(env, cmdline, fetch_item.origin_id(), counts.x_fetches, counts.y_fetches, true, *active_state))
+ if (! do_fetch(env, cmdline, fetch_item.origin_id_spec(), counts.x_fetches, counts.y_fetches, true, *active_state))
{
fetch_item.set_state(active_state->failed());
return 1;
@@ -797,46 +813,63 @@ namespace
}
};
+ std::string stringify_id_or_spec(
+ const std::tr1::shared_ptr<Environment> & env,
+ const PackageDepSpec & spec)
+ {
+ const std::tr1::shared_ptr<const PackageIDSequence> ids((*env)[selection::RequireExactlyOne(
+ generator::Matches(spec, MatchPackageOptions()))]);
+ if (ids->empty())
+ return stringify(spec);
+ else
+ return stringify(**ids->begin());
+ }
+
struct AlreadyDoneVisitor
{
+ const std::tr1::shared_ptr<Environment> env;
ExecuteCounts & counts;
int x, y;
std::string text;
- AlreadyDoneVisitor(ExecuteCounts & c) :
+ AlreadyDoneVisitor(
+ const std::tr1::shared_ptr<Environment> & e,
+ ExecuteCounts & c) :
+ env(e),
counts(c)
{
}
void visit(const InstallJob & j)
{
- text = "install " + stringify(*j.origin_id());
+ text = "install " + stringify_id_or_spec(env, j.origin_id_spec());
x = ++counts.x_installs;
y = counts.y_installs;
}
void visit(const FetchJob & j)
{
- text = "fetch " + stringify(*j.origin_id());
+ text = "fetch " + stringify_id_or_spec(env, j.origin_id_spec());
x = ++counts.x_fetches;
y = counts.y_fetches;
}
void visit(const UninstallJob & j)
{
- text = "uninstall " + join(indirect_iterator(j.ids_to_remove()->begin()),
- indirect_iterator(j.ids_to_remove()->end()), ", ");
+ text = "uninstall " + join(j.ids_to_remove_specs()->begin(), j.ids_to_remove_specs()->end(), ", ",
+ std::tr1::bind(&stringify_id_or_spec, env, std::tr1::placeholders::_1));
x = ++counts.x_installs;
y = counts.y_installs;
}
};
void already_done_action(
+ const std::tr1::shared_ptr<Environment> & env,
const std::string & state,
const std::tr1::shared_ptr<const ExecuteJob> & job,
ExecuteCounts & counts)
{
- AlreadyDoneVisitor v(counts);
+ AlreadyDoneVisitor v(env, counts);
job->accept(v);
cout << endl;
cout << c::bold_green() << v.x << " of " << v.y << ": Already " << state << " for "
@@ -891,18 +924,18 @@ namespace
{
retcode = 1;
want = false;
- already_done_action("failed", *c, counts);
+ already_done_action(env, "failed", *c, counts);
}
else if (initial_state.skipped)
{
retcode = 1;
want = false;
- already_done_action("skipped", *c, counts);
+ already_done_action(env, "skipped", *c, counts);
}
else if (initial_state.done)
{
want = false;
- already_done_action("succeeded", *c, counts);
+ already_done_action(env, "succeeded", *c, counts);
}
}
@@ -970,30 +1003,44 @@ namespace
struct SummaryNameVisitor
{
+ const std::tr1::shared_ptr<Environment> env;
+
+ SummaryNameVisitor(const std::tr1::shared_ptr<Environment> & e) :
+ env(e)
+ {
+ }
+
std::string visit(const FetchJob & j) const
{
- return "fetch " + stringify(*j.origin_id());
+ return "fetch " + stringify_id_or_spec(env, j.origin_id_spec());
}
std::string visit(const InstallJob & j) const
{
- return "install " + stringify(*j.origin_id()) + " to " + stringify(j.destination_repository_name());
+ return "install " + stringify_id_or_spec(env, j.origin_id_spec()) + " to " + stringify(j.destination_repository_name());
}
std::string visit(const UninstallJob & j) const
{
- return "uninstall " + join(indirect_iterator(j.ids_to_remove()->begin()), indirect_iterator(j.ids_to_remove()->end()), ", ");
+ return "uninstall " + join(j.ids_to_remove_specs()->begin(), j.ids_to_remove_specs()->end(), ", ",
+ std::tr1::bind(&stringify_id_or_spec, env, std::tr1::placeholders::_1));
}
};
struct SummaryDisplayer
{
+ const std::tr1::shared_ptr<Environment> env;
const std::tr1::shared_ptr<const ExecuteJob> job;
const bool something_failed;
bool & done_heading;
- SummaryDisplayer(const std::tr1::shared_ptr<const ExecuteJob> & j, const bool s, bool & b) :
+ SummaryDisplayer(
+ const std::tr1::shared_ptr<Environment> & e,
+ const std::tr1::shared_ptr<const ExecuteJob> & j,
+ const bool s,
+ bool & b) :
+ env(e),
job(j),
something_failed(s),
done_heading(b)
@@ -1012,13 +1059,15 @@ namespace
void visit(const JobActiveState &) const
{
need_heading();
- cout << c::bold_yellow() << "pending: " << job->accept_returning<std::string>(SummaryNameVisitor()) << c::normal() << endl;
+ cout << c::bold_yellow() << "pending: " << job->accept_returning<std::string>(
+ SummaryNameVisitor(env)) << c::normal() << endl;
}
void visit(const JobPendingState &) const
{
need_heading();
- cout << c::bold_yellow() << "pending: " << job->accept_returning<std::string>(SummaryNameVisitor()) << c::normal() << endl;
+ cout << c::bold_yellow() << "pending: " << job->accept_returning<std::string>(
+ SummaryNameVisitor(env)) << c::normal() << endl;
}
void visit(const JobSucceededState & s) const
@@ -1027,14 +1076,16 @@ namespace
|| (something_failed && ! simple_visitor_cast<const FetchJob>(*job)))
{
need_heading();
- cout << c::bold_green() << "succeeded: " << job->accept_returning<std::string>(SummaryNameVisitor()) << c::normal() << endl;
+ cout << c::bold_green() << "succeeded: " << job->accept_returning<std::string>(
+ SummaryNameVisitor(env)) << c::normal() << endl;
}
}
void visit(const JobFailedState &) const
{
need_heading();
- cout << c::bold_red() << "failed: " << job->accept_returning<std::string>(SummaryNameVisitor()) << c::normal() << endl;
+ cout << c::bold_red() << "failed: " << job->accept_returning<std::string>(
+ SummaryNameVisitor(env)) << c::normal() << endl;
}
void visit(const JobSkippedState &) const
@@ -1042,12 +1093,14 @@ namespace
if (! simple_visitor_cast<const FetchJob>(*job))
{
need_heading();
- cout << c::bold_yellow() << "skipped: " << job->accept_returning<std::string>(SummaryNameVisitor()) << c::normal() << endl;
+ cout << c::bold_yellow() << "skipped: " << job->accept_returning<std::string>(
+ SummaryNameVisitor(env)) << c::normal() << endl;
}
}
};
void display_summary(
+ const std::tr1::shared_ptr<Environment> & env,
const std::tr1::shared_ptr<JobLists> & lists,
const bool something_failed)
{
@@ -1057,7 +1110,7 @@ namespace
c_end(lists->execute_job_list()->end()) ;
c != c_end ; ++c)
{
- (*c)->state()->accept(SummaryDisplayer(*c, something_failed, done_heading));
+ (*c)->state()->accept(SummaryDisplayer(env, *c, something_failed, done_heading));
(*c)->set_state(make_null_shared_ptr());
}
}
@@ -1127,7 +1180,7 @@ namespace
write_resume_file(env, lists, cmdline);
if (! cmdline.a_pretend.specified())
- display_summary(lists, 0 != retcode);
+ display_summary(env, lists, 0 != retcode);
if (0 != env->perform_hook(Hook("install_task_execute_post")
("TARGETS", join(cmdline.begin_parameters(), cmdline.end_parameters(), " "))
@@ -1142,7 +1195,7 @@ namespace
write_resume_file(env, lists, cmdline);
if (! cmdline.a_pretend.specified())
- display_summary(lists, 0 != retcode);
+ display_summary(env, lists, 0 != retcode);
if (0 != env->perform_hook(Hook("install_task_execute_post")
("TARGETS", join(cmdline.begin_parameters(), cmdline.end_parameters(), " "))