summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault (JBoss)2013-04-27 00:39:51 (EDT)
committerPascal Rapicault2013-04-27 00:39:51 (EDT)
commit92fca1336ceadf40e2379dc0519d0214b6773d0c (patch)
tree5e16b1af63be137aff38a5abbdfb73899ea4a359
parent1afc2baced98f028b1dd4cd071c939566471680a (diff)
downloadrt.equinox.p2-92fca1336ceadf40e2379dc0519d0214b6773d0c.zip
rt.equinox.p2-92fca1336ceadf40e2379dc0519d0214b6773d0c.tar.gz
rt.equinox.p2-92fca1336ceadf40e2379dc0519d0214b6773d0c.tar.bz2
Check is the new request is useful
-rw-r--r--bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/RequestFlexer.java19
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TestRequestFlexerIUProperties.java17
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TestRequestFlexerRequestWithRemoval.java3
3 files changed, 19 insertions, 20 deletions
diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/RequestFlexer.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/RequestFlexer.java
index be05363..8d66a48 100644
--- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/RequestFlexer.java
+++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/RequestFlexer.java
@@ -97,15 +97,23 @@ public class RequestFlexer {
return null;
}
IProfileChangeRequest effectiveRequest = computeEffectiveChangeRequest(intermediaryPlan, loosenedRequest, request);
- if (effectiveRequest.getAdditions().isEmpty() && effectiveRequest.getRemovals().isEmpty())
+ if (isRequestUseless(effectiveRequest))
return null;
return effectiveRequest;
}
+ private boolean isRequestUseless(IProfileChangeRequest effectiveRequest) {
+ if (effectiveRequest.getAdditions().isEmpty() && effectiveRequest.getRemovals().isEmpty())
+ return true;
+ if (effectiveRequest.getRemovals().containsAll(effectiveRequest.getAdditions()))
+ return true;
+ return false;
+ }
+
private boolean canShortCircuit(IProfileChangeRequest originalRequest) {
//Case where the user is asking to install only some of the requested IUs but there is only one IU to install.
if (allowPartialInstall && !allowInstalledUpdate && !allowDifferentVersion && !allowInstalledRemoval)
- if (originalRequest.getAdditions().size() == 1 && originalRequest.getRemovals().isEmpty())
+ if (originalRequest.getAdditions().size() == 1)
return true;
//When we can find a different version of the IU but the only version available is the one the user is asking to install
@@ -117,6 +125,9 @@ public class RequestFlexer {
if (!foundDifferentVersionsForElementsInstalled)
return true;
+ if (!allowPartialInstall && !allowInstalledUpdate && !allowDifferentVersion && !allowInstalledRemoval)
+ return true;
+
return false;
}
@@ -219,7 +230,7 @@ public class RequestFlexer {
//First deal with the IUs that are being added
Collection<IInstallableUnit> requestedAdditions = originalRequest.getAdditions();
for (IInstallableUnit addedIU : requestedAdditions) {
- Collection<IInstallableUnit> potentialUpdates = allowDifferentVersion ? findAllVersionsAvailable(addedIU) : new ArrayList();
+ Collection<IInstallableUnit> potentialUpdates = allowDifferentVersion ? findAllVersionsAvailable(addedIU) : new ArrayList<IInstallableUnit>();
foundDifferentVersionsForElementsToInstall = (foundDifferentVersionsForElementsToInstall || (potentialUpdates.size() == 0 ? false : true));
potentialUpdates.add(addedIU); //Make sure that we include the IU that we were initially trying to install
@@ -312,6 +323,8 @@ public class RequestFlexer {
//Loosen up the IUs that are already part of the profile
//Given how we are creating our request, this needs to take into account the removal from the original request as well as the change in inclusion
private IProfileChangeRequest loosenUpInstalledSoftware(IProfileChangeRequest request, IProfileChangeRequest originalRequest) {
+ if (!allowInstalledRemoval && !allowInstalledUpdate)
+ return request;
Set<IInstallableUnit> allRoots = getRoots();
for (IInstallableUnit existingIU : allRoots) {
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TestRequestFlexerIUProperties.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TestRequestFlexerIUProperties.java
index 598cc39..a3dad16 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TestRequestFlexerIUProperties.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TestRequestFlexerIUProperties.java
@@ -75,14 +75,6 @@ public class TestRequestFlexerIUProperties extends AbstractProvisioningTest {
assertNotOK(planner.getProvisioningPlan(originalRequest, null, null).getStatus());
{
- //sdk1 is requested to be marked strict, so since sdk1 and egit can't be installed together and we don't have any flexibility, we get null
- RequestFlexer av = new RequestFlexer(planner);
- av.setProvisioningContext(context);
- IProfileChangeRequest realRequest = av.getChangeRequest(originalRequest, profile, new NullProgressMonitor());
- assertNull(realRequest);
- }
-
- {
//Verify that it is possible to install egit2 because the sdk1 is optional
RequestFlexer av = new RequestFlexer(planner);
av.setAllowInstalledElementChange(true);
@@ -134,14 +126,7 @@ public class TestRequestFlexerIUProperties extends AbstractProvisioningTest {
{
//Verify that it is possible to install egit2 because the sdk1 inclusion is change to optional
- RequestFlexer av = new RequestFlexer(planner);
- av.setProvisioningContext(context);
- IProfileChangeRequest realRequest = av.getChangeRequest(originalRequest, profile, new NullProgressMonitor());
- assertTrue(realRequest.getAdditions().contains(egit2));
- assertTrue(realRequest.getRemovals().contains(sdk1));
- assertEquals(1, realRequest.getAdditions().size());
- assertEquals(1, realRequest.getRemovals().size());
- assertResolve(realRequest, planner);
+ assertResolve(originalRequest, planner);
}
{
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TestRequestFlexerRequestWithRemoval.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TestRequestFlexerRequestWithRemoval.java
index 571d68c..d194c0b 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TestRequestFlexerRequestWithRemoval.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TestRequestFlexerRequestWithRemoval.java
@@ -76,8 +76,9 @@ public class TestRequestFlexerRequestWithRemoval extends AbstractProvisioningTes
{
RequestFlexer av = new RequestFlexer(planner);
av.setProvisioningContext(context);
+ av.setAllowDifferentVersion(true);
IProfileChangeRequest realRequest = av.getChangeRequest(originalRequest, profile, new NullProgressMonitor());
- assertTrue(realRequest.getAdditions().contains(egit2));
+ assertTrue(realRequest.getAdditions().contains(egit1));
assertTrue(realRequest.getRemovals().contains(sdk1));
assertEquals(1, realRequest.getAdditions().size());
assertResolve(realRequest, planner);