Bug 464084 - Update the felix resolver implementation to the latest
 - update to use the term delta
diff --git a/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/Candidates.java b/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/Candidates.java
index e5501d4..8ab895c 100644
--- a/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/Candidates.java
+++ b/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/Candidates.java
@@ -73,7 +73,7 @@
 
     private final Map<Capability, Requirement> m_subtitutableMap;
 
-    private final OpenHashMapSet<Requirement, Capability> m_path;
+    private final OpenHashMapSet<Requirement, Capability> m_delta;
 
     /**
      * Private copy constructor used by the copy() method.
@@ -86,7 +86,7 @@
         boolean fragmentsPresent,
         Map<Resource, Boolean> onDemandResources,
         Map<Capability, Requirement> substitutableMap,
-        OpenHashMapSet<Requirement, Capability> path)
+        OpenHashMapSet<Requirement, Capability> delta)
     {
         m_mandatoryResources = mandatoryResources;
         m_dependentMap = dependentMap;
@@ -96,7 +96,7 @@
         m_fragmentsPresent = fragmentsPresent;
         m_validOnDemandResources = onDemandResources;
         m_subtitutableMap = substitutableMap;
-        m_path = path;
+        m_delta = delta;
     }
 
     /**
@@ -111,11 +111,16 @@
         m_populateResultCache = new LinkedHashMap<Resource, Object>();
         m_validOnDemandResources = validOnDemandResources;
         m_subtitutableMap = new LinkedHashMap<Capability, Requirement>();
-        m_path = new OpenHashMapSet<Requirement, Capability>(3);
+        m_delta = new OpenHashMapSet<Requirement, Capability>(3);
     }
 
-    public Object getPath() {
-        return m_path;
+    /**
+     * Returns the delta which is the differences in the candidates from the
+     * original Candidates permutation.
+     * @return the delta
+     */
+    public Object getDelta() {
+        return m_delta;
     }
 
     /**
@@ -834,11 +839,11 @@
         {
             m_candidateMap.remove(req);
         }
-        // Update resolution path
-        CopyOnWriteSet<Capability> capPath = m_path.get(req);
+        // Update the delta with the removed capability
+        CopyOnWriteSet<Capability> capPath = m_delta.get(req);
         if (capPath == null) {
             capPath = new CopyOnWriteSet<Capability>();
-            m_path.put(req, capPath);
+            m_delta.put(req, capPath);
         }
         capPath.add(cap);
     }
@@ -847,11 +852,11 @@
     {
         List<Capability> l = m_candidateMap.get(req);
         l.removeAll(caps);
-        // Update resolution path
-        CopyOnWriteSet<Capability> capPath = m_path.get(req);
+        // Update candidates delta with the removed capabilities.
+        CopyOnWriteSet<Capability> capPath = m_delta.get(req);
         if (capPath == null) {
             capPath = new CopyOnWriteSet<Capability>();
-            m_path.put(req, capPath);
+            m_delta.put(req, capPath);
         }
         capPath.addAll(caps);
         return l;
@@ -1272,7 +1277,7 @@
                 m_fragmentsPresent,
                 m_validOnDemandResources,
                 m_subtitutableMap,
-                m_path.deepClone());
+                m_delta.deepClone());
     }
 
     public void dump(ResolveContext rc)
diff --git a/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/ResolverImpl.java b/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/ResolverImpl.java
index 381240b..2264826 100644
--- a/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/ResolverImpl.java
+++ b/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/ResolverImpl.java
@@ -208,7 +208,7 @@
                     }
                 }
 
-                Set<Object> donePaths = new HashSet<Object>();
+                Set<Object> processedDeltas = new HashSet<Object>();
                 Map<Resource, ResolutionException> faultyResources = null;
                 do
                 {
@@ -221,8 +221,11 @@
                     {
                         break;
                     }
-                    if (!donePaths.add(allCandidates.getPath()))
+                    // The delta is used to detect that we have already processed this particular permutation
+                    if (!processedDeltas.add(allCandidates.getDelta()))
                     {
+                        // This permutation has already been tried
+                        // Don't try it again
                         continue;
                     }