From 7253de0bb973bd8122997a44888a68b3cccd03df Mon Sep 17 00:00:00 2001 From: kohsuke Date: Sun, 14 Jan 2007 05:54:15 +0000 Subject: [PATCH] supported progressive log output. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@1751 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/main/java/hudson/scm/CVSSCM.java | 32 +++++++++++++++++-- .../scm/CVSSCM/TagAction/inProgress.jelly | 24 ++++++++++---- 2 files changed, 48 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/hudson/scm/CVSSCM.java b/core/src/main/java/hudson/scm/CVSSCM.java index 4dd6577dd7..d1f0cb80a5 100644 --- a/core/src/main/java/hudson/scm/CVSSCM.java +++ b/core/src/main/java/hudson/scm/CVSSCM.java @@ -19,6 +19,7 @@ import hudson.model.Project; import hudson.model.Job; import hudson.model.Run; import hudson.model.AbstractModelObject; +import hudson.model.LargeText; import hudson.org.apache.tools.ant.taskdefs.cvslib.ChangeLogTask; import hudson.remoting.RemoteOutputStream; import hudson.remoting.VirtualChannel; @@ -26,6 +27,7 @@ import hudson.util.ArgumentListBuilder; import hudson.util.ForkOutputStream; import hudson.util.FormFieldValidator; import hudson.util.StreamTaskListener; +import hudson.util.ByteBuffer; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.taskdefs.Expand; import org.apache.tools.zip.ZipEntry; @@ -67,6 +69,7 @@ import java.util.Enumeration; import java.util.Map.Entry; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.lang.ref.WeakReference; /** * CVS. @@ -916,6 +919,11 @@ public class CVSSCM extends AbstractCVSFamilySCM implements Serializable { */ private transient volatile TagWorkerThread workerThread; + /** + * Hold the log of "cvs tag" operation. + */ + private transient WeakReference log; + public TagAction(AbstractBuild build) { this.build = build; } @@ -1013,6 +1021,21 @@ public class CVSSCM extends AbstractCVSFamilySCM implements Serializable { doIndex(req,rsp); } + /** + * Handles incremental log output. + */ + public void doProgressiveLog( StaplerRequest req, StaplerResponse rsp) throws IOException { + if(log==null) { + rsp.setStatus(HttpServletResponse.SC_OK); + } else { + LargeText text = log.get(); + if(text!=null) + text.doProgressText(req,rsp); + else + rsp.setStatus(HttpServletResponse.SC_OK); + } + } + /** * Performs tagging. */ @@ -1084,7 +1107,8 @@ public class CVSSCM extends AbstractCVSFamilySCM implements Serializable { public static final class TagWorkerThread extends Thread { // StringWriter is synchronized - private final ByteArrayOutputStream log = new ByteArrayOutputStream(); + private final ByteBuffer log = new ByteBuffer(); + private final LargeText text = new LargeText(log,false); private final Map tagSet; public TagWorkerThread(Map tagSet) { @@ -1099,8 +1123,10 @@ public class CVSSCM extends AbstractCVSFamilySCM implements Serializable { public synchronized void start() { for (Entry e : tagSet.entrySet()) { TagAction ta = e.getKey().getAction(TagAction.class); - if(ta!=null) + if(ta!=null) { ta.workerThread = this; + ta.log = new WeakReference(text); + } } super.start(); @@ -1119,6 +1145,8 @@ public class CVSSCM extends AbstractCVSFamilySCM implements Serializable { ta.perform(e.getValue(), listener); listener.getLogger().println(); } + + listener.getLogger().println("Completed"); } } diff --git a/core/src/main/resources/hudson/scm/CVSSCM/TagAction/inProgress.jelly b/core/src/main/resources/hudson/scm/CVSSCM/TagAction/inProgress.jelly index e08a617022..37cb24fd75 100644 --- a/core/src/main/resources/hudson/scm/CVSSCM/TagAction/inProgress.jelly +++ b/core/src/main/resources/hudson/scm/CVSSCM/TagAction/inProgress.jelly @@ -6,12 +6,24 @@

Tagging is in progress.

-
- -
- -
-
+ + + + +

+          
+ +
+ +
+ + +
+
+ +
+
+
\ No newline at end of file