diff --git a/core/src/main/java/hudson/model/AbstractBuild.java b/core/src/main/java/hudson/model/AbstractBuild.java index e15b23a98c..aed3ca9399 100644 --- a/core/src/main/java/hudson/model/AbstractBuild.java +++ b/core/src/main/java/hudson/model/AbstractBuild.java @@ -411,12 +411,23 @@ public abstract class AbstractBuild

,R extends Abs public String getWhyKeepLog() { // if any of the downstream project is configured with 'keep dependency component', // we need to keep this log + OUTER: for (AbstractProject p : getParent().getDownstreamProjects()) { if(!p.isKeepDependencies()) continue; + AbstractBuild fb = p.getFirstBuild(); + if(fb==null) continue; // no active record + + // is there any active build that depends on us? for(int i : getDownstreamRelationship(p).listNumbersReverse()) { + // TODO: this is essentially a "find intersection between two sparse sequences" + // and we should be able to do much better. + + if(i b = p.getBuildByNumber(i); - if(b!=null && b.isKeepLog()) + if(b!=null) return Messages.AbstractBuild_KeptBecause(b); } }