This patch changes the order of depency resolution from depth-first to
breadth-first, which I *think* ensures that dynamic revision patterns
are always replaced with static revision numbers prior to conflict
resolution.

If I understand things correctly, this patch makes the logic in
LatestRevisionStrategy that deals with dynamic revisions unnecessary.

=== src/java/org/apache/ivy/Ivy.java
==================================================================
--- src/java/org/apache/ivy/Ivy.java	(revision 647)
+++ src/java/org/apache/ivy/Ivy.java	(revision 648)
@@ -41,6 +41,7 @@
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.ListIterator;
 import java.util.Map;
@@ -1352,7 +1353,11 @@
                 rootNode.updateConfsToFetch(Collections.singleton(confs[i]));
                 
                 // go fetch !
-                fetchDependencies(rootNode, confs[i], false);
+                LinkedList queue = new LinkedList();
+                queue.add(new FetchParams(rootNode, confs[i], false));
+                while (!queue.isEmpty()) {
+                    fetchDependencies(queue);
+                }
             }
         }
         
@@ -1415,10 +1420,25 @@
         return (IvyNode[]) dependencies.toArray(new IvyNode[dependencies.size()]);
     }
 
+    private static class FetchParams {
+        public final IvyNode node;
+        public final String conf;
+        public final boolean shouldBePublic;
 
+        public FetchParams(IvyNode node, String conf, boolean shouldBePublic) {
+            this.node = node;
+            this.conf = conf;
+            this.shouldBePublic = shouldBePublic;
+        }
+    }
     
     
-    private void fetchDependencies(IvyNode node, String conf, boolean shouldBePublic) {
+    private void fetchDependencies(LinkedList queue) {
+        final FetchParams params = (FetchParams)queue.removeFirst();
+        IvyNode node = params.node;
+        String conf = params.conf;
+        boolean shouldBePublic = params.shouldBePublic;
+        
     	checkInterrupted();
         long start = System.currentTimeMillis();
         if (debugConflictResolution()) {
@@ -1433,7 +1453,7 @@
             if (!node.isEvicted(node.getRootModuleConf())) {
                 String[] confs = node.getRealConfs(conf);
                 for (int i = 0; i < confs.length; i++) {
-                    doFetchDependencies(node, confs[i]);
+                    doFetchDependencies(node, confs[i], queue);
                 }
             }
         } else if (!node.hasProblem()) {
@@ -1442,7 +1462,7 @@
             if (!node.isEvicted(node.getRootModuleConf())) {
                 String[] confs = node.getRealConfs(conf);
                 for (int i = 0; i < confs.length; i++) {
-                    doFetchDependencies(node, confs[i]);
+                    doFetchDependencies(node, confs[i], queue);
                 }
             }
         }
@@ -1452,7 +1472,7 @@
             if (ed.getSelected() != null) {
             	for (Iterator iter = ed.getSelected().iterator(); iter.hasNext();) {
             		IvyNode selected = (IvyNode)iter.next();
-            		fetchDependencies(selected, conf, true);
+                    queue.addLast(new FetchParams(selected, conf, true));
             	}
             }
         }
@@ -1461,7 +1481,7 @@
         }
     }
 
-    private void doFetchDependencies(IvyNode node, String conf) {
+    private void doFetchDependencies(IvyNode node, String conf, LinkedList queue) {
         Configuration c = node.getConfiguration(conf);
         if (c == null) {
             Message.warn("configuration not found '"+conf+"' in "+node.getResolvedId()+": ignoring");
@@ -1485,7 +1505,8 @@
             node.updateConfsToFetch(Arrays.asList(extendedConfs));
         }
         for (int i = 0; i < extendedConfs.length; i++) {
-            fetchDependencies(node, extendedConfs[i], false);
+            queue.addLast(new FetchParams(node, extendedConfs[i], false));
+            //fetchDependencies(node, extendedConfs[i], false);
         }
         
         // now we can actually resolve this configuration dependencies
@@ -1501,13 +1522,15 @@
                 }
                 String[] confs = dep.getRequiredConfigurations(node, conf);
                 for (int i = 0; i < confs.length; i++) {
-                    fetchDependencies(dep, confs[i], true);
+                    queue.addLast(new FetchParams(dep, confs[i], true));
+                    //fetchDependencies(dep, confs[i], true);
                 }
                 // if there are still confs to fetch (usually because they have
                 // been updated when evicting another module), we fetch them now
                 confs = dep.getConfsToFetch();
                 for (int i = 0; i < confs.length; i++) {
-                    fetchDependencies(dep, confs[i], true);
+                    queue.addLast(new FetchParams(dep, confs[i], true));
+                    //fetchDependencies(dep, confs[i], true);
                 }
             }
         }
