Bit of performance optimization.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@8354 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
kohsuke committed 2008-04-07 22:08:29 +00:00
1 parent d6a660040e
commit 7c4abd909a
3 files changed
+36 -13

No files matched your search

@@ -411,20 +411,20 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
public String getWhyKeepLog() {
// if any of the downstream project is configured with 'keep dependency component',
// we need to keep this log
for (Map.Entry<AbstractProject, RangeSet> e : getDownstreamBuilds().entrySet()) {
AbstractProject<?,?> p = e.getKey();
if(!p.isKeepDependencies()) continue;
for (AbstractProject<?,?> p : getParent().getDownstreamProjects()) {
if(!p.isKeepDependencies()) continue;
// is there any active build that depends on us?
for (AbstractBuild build : p.getBuilds()) {
if(e.getValue().includes(build.getNumber()))
return Messages.AbstractBuild_KeptBecause(build);
for(int i : getDownstreamRelationship(p).listNumbersReverse()) {
AbstractBuild<?, ?> b = p.getBuildByNumber(i);
if(b!=null && b.isKeepLog())
return Messages.AbstractBuild_KeptBecause(b);
}
}
return super.getWhyKeepLog();
}
/**
* Gets the dependency relationship from this build (as the source)
* and that project (as the sink.)
@@ -14,6 +14,7 @@ import hudson.maven.MavenModuleSet;
import hudson.util.HexBinaryConverter;
import hudson.util.Iterators;
import hudson.util.XStream2;
import hudson.util.AdaptedIterator;
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;
@@ -233,7 +234,7 @@ public class Fingerprint implements ModelObject {
}
/**
* List all numbers in this range set.
* List all numbers in this range set, in the ascending order.
*/
public Iterable<Integer> listNumbers() {
final List<Range> ranges = getRanges();
@@ -248,6 +249,25 @@ public class Fingerprint implements ModelObject {
};
}
// /**
// * List up builds.
// */
// public <J extends Job<J,R>,R extends Run<J,R>> Iterable<R> listBuilds(final J job) {
// return new Iterable<R>() {
// public Iterator<R> iterator() {
// return new Iterators.FilterIterator<R>(new AdaptedIterator<Integer,R>(listNumbers().iterator()) {
// protected R adapt(Integer n) {
// return job.getBuildByNumber(n);
// }
// }) {
// protected boolean filter(R r) {
// return r!=null;
// }
// };
// }
// };
// }
/**
* List all numbers in this range set in the descending order.
*/
+8 -5
View File
@@ -1021,19 +1021,22 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
public void doToggleLogKeep( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
checkPermission(UPDATE);
keepLog = !keepLog;
save();
keepLog(!keepLog);
rsp.forwardToPreviousPage(req);
}
/**
* Marks this build to keep the log.
*/
public void keepLog() throws IOException {
keepLog = true;
public final void keepLog() throws IOException {
keepLog(true);
}
public void keepLog(boolean newValue) throws IOException {
keepLog = newValue;
save();
}
/**
* Deletes the build when the button is pressed.
*/