Author: xavier
Date: Fri Feb 23 09:43:50 2007
New Revision: 511035
URL: http://svn.apache.org/viewvc?view=rev&rev=511035
Log:
FIX: latest-time conflict manager not working properly (IVY-407)
Added:
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/ivy-latest-time-1.xml
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/ivy-latest-time-2.xml
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/ivyconf-latest-time.xml
Modified:
incubator/ivy/core/trunk/CHANGES.txt
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNodeEviction.java
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/conflict/ConflictManager.java
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/conflict/LatestConflictManager.java
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/LatestConflictManagerTest.java
Modified: incubator/ivy/core/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/CHANGES.txt?view=diff&rev=511035&r1=511034&r2=511035
==============================================================================
--- incubator/ivy/core/trunk/CHANGES.txt (original)
+++ incubator/ivy/core/trunk/CHANGES.txt Fri Feb 23 09:43:50 2007
@@ -13,6 +13,7 @@
- IMPROVE: Refactoring / documentation / test of matcher package (IVY-375)
(thanks to Stephane Baillez)
- IMPROVE: Add a unit test to verify that latest.integration accepts released
modules (IVY-394) (thanks to Gilles Scokart)
+- FIX: latest-time conflict manager not working properly (IVY-407)
- FIX: LatestRevisionStrategy do not consider all dynamic revisions properly
(IVY-383) (thanks to John Williams for the unit test)
- FIX: IOException during publish causes NullPointerException (IVY-371)
- FIX: Comments in ivy.xml duplicated (IVY-336) (thanks to Gilles Scokart)
Modified:
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java
URL:
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java?view=diff&rev=511035&r1=511034&r2=511035
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java
(original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java
Fri Feb 23 09:43:50 2007
@@ -909,6 +909,18 @@
return 0;
}
+ /**
+ * Returns the last modified timestamp of the module represented by this
Node,
+ * or 0 if the last modified timestamp is currently unkwown (module not
loaded)
+ * @return the last modified timestamp of the module represented by this
Node
+ */
+ public long getLastModified() {
+ if (_md != null) {
+ return _md.getLastModified();
+ }
+ return 0;
+ }
+
public ModuleRevisionId getResolvedId() {
if (_md != null && _md.getResolvedModuleRevisionId().getRevision() !=
null) {
return _md.getResolvedModuleRevisionId();
Modified:
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNodeEviction.java
URL:
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNodeEviction.java?view=diff&rev=511035&r1=511034&r2=511035
==============================================================================
---
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNodeEviction.java
(original)
+++
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNodeEviction.java
Fri Feb 23 09:43:50 2007
@@ -192,13 +192,14 @@
public boolean isEvicted(String rootModuleConf) {
- cleanEvicted();
+ cleanEvicted();
IvyNode root = _node.getRoot();
- return root != _node
+ return root != _node
&& !root.getResolvedRevisions(
_node.getId().getModuleId(),
rootModuleConf)
- .contains(_node.getResolvedId());
+ .contains(_node.getResolvedId())
+ && getEvictedData(rootModuleConf) != null;
}
public boolean isCompletelyEvicted() {
@@ -242,7 +243,7 @@
public void markEvicted(EvictionData evictionData) {
_evicted.put(evictionData.getRootModuleConf(), evictionData);
}
-
+
public EvictionData getEvictedData(String rootModuleConf) {
cleanEvicted();
return (EvictionData)_evicted.get(rootModuleConf);
Modified:
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java
URL:
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java?view=diff&rev=511035&r1=511034&r2=511035
==============================================================================
---
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java
(original)
+++
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java
Fri Feb 23 09:43:50 2007
@@ -590,12 +590,21 @@
// compute conflicts
Collection resolvedNodes = new
HashSet(ancestor.getNode().getResolvedNodes(node.getModuleId(),
node.getRootModuleConf()));
Collection conflicts = computeConflicts(node, ancestor, toevict,
resolvedNodes);
+
if (_settings.debugConflictResolution()) {
Message.debug("found conflicting revisions for "+node+" in
"+ancestor+": "+conflicts);
}
ConflictManager conflictManager =
ancestor.getNode().getConflictManager(node.getModuleId());
Collection resolved =
conflictManager.resolveConflicts(ancestor.getNode(), conflicts);
+
+ if (resolved == null) {
+ if (_settings.debugConflictResolution()) {
+ Message.debug("impossible to resolve conflicts for "+node+" in
"+ancestor+" yet");
+ }
+ return;
+ }
+
if (_settings.debugConflictResolution()) {
Message.debug("selected revisions for "+node+" in "+ancestor+":
"+resolved);
}
Modified:
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/conflict/ConflictManager.java
URL:
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/conflict/ConflictManager.java?view=diff&rev=511035&r1=511034&r2=511035
==============================================================================
---
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/conflict/ConflictManager.java
(original)
+++
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/conflict/ConflictManager.java
Fri Feb 23 09:43:50 2007
@@ -26,9 +26,16 @@
* Resolves the eventual conflicts found in the given collection of
IvyNode.
* This method return a Collection of IvyNode which have not been evicted.
* The given conflicts Collection contains at least one IvyNode.
+ *
+ * This method can be called with IvyNodes which are not yet loaded.
+ * If this conflict manager is not able to resolve conflicts with the
current
+ * data found in the IvyNodes and need them to be fully loaded, it will
+ * return null to indicate that no conflict resolution has been done.
+ *
* @param parent the ivy node parent for which the conflict is to be
resolved
* @param conflicts the collection of IvyNode to check for conflicts
- * @return a Collection of IvyNode which have not been evicted
+ * @return a Collection of IvyNode which have not been evicted, or null if
+ * conflict management resolution is not possible yet
*/
Collection resolveConflicts(IvyNode parent, Collection conflicts);
String getName();
Modified:
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/conflict/LatestConflictManager.java
URL:
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/conflict/LatestConflictManager.java?view=diff&rev=511035&r1=511034&r2=511035
==============================================================================
---
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/conflict/LatestConflictManager.java
(original)
+++
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/conflict/LatestConflictManager.java
Fri Feb 23 09:43:50 2007
@@ -31,7 +31,11 @@
public class LatestConflictManager extends AbstractConflictManager {
- private static class IvyNodeArtifactInfo implements ArtifactInfo {
+ public static class NoConflictResolvedYetException extends
RuntimeException {
+ }
+
+
+ private static class IvyNodeArtifactInfo implements ArtifactInfo {
private final IvyNode _node;
private IvyNodeArtifactInfo(IvyNode dep) {
@@ -39,7 +43,15 @@
}
public long getLastModified() {
- return _node.getPublication();
+ long lastModified = _node.getLastModified();
+ if (lastModified == 0) {
+ // if the last modified timestamp is unknown, we can't
resolve
+ // the conflicts now, and trigger an exception which
will be catched
+ // in the main resolveConflicts method
+ throw new NoConflictResolvedYetException();
+ } else {
+ return lastModified;
+ }
}
public String getRevision() {
@@ -80,11 +92,17 @@
return Collections.singleton(node);
}
}
- ArtifactInfo latest =
getStrategy().findLatest(toArtifactInfo(conflicts), null);
- if (latest != null) {
- return
Collections.singleton(((IvyNodeArtifactInfo)latest).getNode());
- } else {
- return conflicts;
+ try {
+ ArtifactInfo latest =
getStrategy().findLatest(toArtifactInfo(conflicts), null);
+ if (latest != null) {
+ return
Collections.singleton(((IvyNodeArtifactInfo)latest).getNode());
+ } else {
+ return conflicts;
+ }
+ } catch (NoConflictResolvedYetException ex) {
+ // we have not enough informations in the nodes to resolve
conflict
+ // according to the resolveConflicts contract, we must return
null
+ return null;
}
}
Modified:
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/LatestConflictManagerTest.java
URL:
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/LatestConflictManagerTest.java?view=diff&rev=511035&r1=511034&r2=511035
==============================================================================
---
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/LatestConflictManagerTest.java
(original)
+++
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/LatestConflictManagerTest.java
Fri Feb 23 09:43:50 2007
@@ -83,6 +83,49 @@
}
}
+ // Test case for issue IVY-407
+ public void testLatestTime1() throws Exception {
+ ivy = new Ivy();
+ ivy.configure(LatestConflictManagerTest.class
+ .getResource("ivyconf-latest-time.xml"));
+ ResolveReport report =
+ ivy.resolve( LatestConflictManagerTest.class.getResource(
"ivy-latest-time-1.xml" ),
+ getResolveOptions() );
+ ConfigurationResolveReport defaultReport =
+ report.getConfigurationReport("default");
+ Iterator iter = defaultReport.getModuleRevisionIds().iterator();
+ while (iter.hasNext()) {
+ ModuleRevisionId mrid = (ModuleRevisionId)iter.next();
+ if (mrid.getName().equals("mod1.1")) {
+ assertEquals("1.0", mrid.getRevision());
+ }
+ else if (mrid.getName().equals("mod1.2")) {
+ assertEquals("2.2", mrid.getRevision());
+ }
+ }
+ }
+
+ public void testLatestTime2() throws Exception {
+ ivy = new Ivy();
+ ivy.configure(LatestConflictManagerTest.class
+ .getResource("ivyconf-latest-time.xml"));
+ ResolveReport report =
+ ivy.resolve( LatestConflictManagerTest.class.getResource(
"ivy-latest-time-2.xml" ),
+ getResolveOptions() );
+ ConfigurationResolveReport defaultReport =
+ report.getConfigurationReport("default");
+ Iterator iter = defaultReport.getModuleRevisionIds().iterator();
+ while (iter.hasNext()) {
+ ModuleRevisionId mrid = (ModuleRevisionId)iter.next();
+ if (mrid.getName().equals("mod1.1")) {
+ assertEquals("1.0", mrid.getRevision());
+ }
+ else if (mrid.getName().equals("mod1.2")) {
+ assertEquals("2.2", mrid.getRevision());
+ }
+ }
+ }
+
private ResolveOptions getResolveOptions() {
return new
ResolveOptions().setCache(CacheManager.getInstance(ivy.getSettings())).setValidate(false);
}
Added:
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/ivy-latest-time-1.xml
URL:
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/ivy-latest-time-1.xml?view=auto&rev=511035
==============================================================================
---
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/ivy-latest-time-1.xml
(added)
+++
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/ivy-latest-time-1.xml
Fri Feb 23 09:43:50 2007
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ivy-module version="1.0">
+ <info organisation="apache" module="resolve-latest-conflict"
revision="1.0" status="release"/>
+ <dependencies>
+ <!-- mod1.1 1.0 depends on mod1.2 2.0 -->
+ <dependency org="org1" name="mod1.1" rev="1.0"/>
+
+ <dependency org="org1" name="mod1.2" rev="2.2"/>
+ </dependencies>
+</ivy-module>
Added:
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/ivy-latest-time-2.xml
URL:
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/ivy-latest-time-2.xml?view=auto&rev=511035
==============================================================================
---
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/ivy-latest-time-2.xml
(added)
+++
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/ivy-latest-time-2.xml
Fri Feb 23 09:43:50 2007
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ivy-module version="1.0">
+ <info organisation="apache" module="resolve-latest-conflict"
revision="1.0" status="release"/>
+ <dependencies>
+ <dependency org="org1" name="mod1.2" rev="2.2"/>
+
+ <!-- mod1.1 1.0 depends on mod1.2 2.0 -->
+ <dependency org="org1" name="mod1.1" rev="1.0"/>
+ </dependencies>
+</ivy-module>
Added:
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/ivyconf-latest-time.xml
URL:
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/ivyconf-latest-time.xml?view=auto&rev=511035
==============================================================================
---
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/ivyconf-latest-time.xml
(added)
+++
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/ivyconf-latest-time.xml
Fri Feb 23 09:43:50 2007
@@ -0,0 +1,12 @@
+<ivyconf>
+
+ <conf defaultResolver="test" defaultConflictManager="latest-time" />
+
+ <resolvers>
+ <filesystem name="test">
+ <artifact
+
pattern="test/repositories/1/[organisation]/[module]/[type]s/[artifact]-[revision].[type]"/>
+ <ivy
pattern="test/repositories/1/[organisation]/[module]/ivys/ivy-[revision].xml"/>
+ </filesystem>
+ </resolvers>
+</ivyconf>