| author | Henrik Lynggaard Hansen | 2012-07-11 15:19:48 (EDT) |
|---|---|---|
| committer | Henrik Lynggaard Hansen | 2012-07-11 15:19:48 (EDT) |
| commit | 4f45e20885f66fa380c4b7455d8b58b8f47b09ea (patch) (side-by-side diff) | |
| tree | 24c9f1a027a99a9db9a01ddaa6ae1c65ee85e81a | |
| parent | 6b2a021db07f935226235132973fb64223c07d91 (diff) | |
| download | org.eclipse.hudson.core-4f45e20885f66fa380c4b7455d8b58b8f47b09ea.zip org.eclipse.hudson.core-4f45e20885f66fa380c4b7455d8b58b8f47b09ea.tar.gz org.eclipse.hudson.core-4f45e20885f66fa380c4b7455d8b58b8f47b09ea.tar.bz2 | |
Reformat the hudson.scm packagesrefs/changes/33/6733/1
Change-Id: Ib0e8123b3608c8c2318ae8430fd0bff5e7faa354
Signed-off-by: Henrik Lynggaard Hansen <henrik@hlyh.dk>
20 files changed, 627 insertions, 604 deletions
diff --git a/hudson-core/src/main/java/hudson/scm/AbstractScmTagAction.java b/hudson-core/src/main/java/hudson/scm/AbstractScmTagAction.java index d003b92..1b3f01b 100644 --- a/hudson-core/src/main/java/hudson/scm/AbstractScmTagAction.java +++ b/hudson-core/src/main/java/hudson/scm/AbstractScmTagAction.java @@ -7,10 +7,10 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: -* + * Contributors: + * * Kohsuke Kawaguchi - * + * * *******************************************************************************/ @@ -30,14 +30,14 @@ import java.io.IOException; /** * Common part of {@link CVSSCM.TagAction} and {@link SubversionTagAction}. * - * <p> - * This class implements the action that tags the modules. Derived classes - * need to provide <tt>tagForm.jelly</tt> view that displays a form for - * letting user start tagging. + * <p> This class implements the action that tags the modules. Derived classes + * need to provide <tt>tagForm.jelly</tt> view that displays a form for letting + * user start tagging. * * @author Kohsuke Kawaguchi */ public abstract class AbstractScmTagAction extends TaskAction implements BuildBadgeAction { + protected final AbstractBuild build; protected AbstractScmTagAction(AbstractBuild build) { @@ -77,13 +77,13 @@ public abstract class AbstractScmTagAction extends TaskAction implements BuildBa } public void doIndex(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { - req.getView(this,chooseAction()).forward(req,rsp); + req.getView(this, chooseAction()).forward(req, rsp); } protected synchronized String chooseAction() { - if(workerThread!=null) + if (workerThread != null) { return "inProgress.jelly"; + } return "tagForm.jelly"; } - } diff --git a/hudson-core/src/main/java/hudson/scm/AutoBrowserHolder.java b/hudson-core/src/main/java/hudson/scm/AutoBrowserHolder.java index 2c1b414..26905f4 100644 --- a/hudson-core/src/main/java/hudson/scm/AutoBrowserHolder.java +++ b/hudson-core/src/main/java/hudson/scm/AutoBrowserHolder.java @@ -7,10 +7,10 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: -* -* Kohsuke Kawaguchi - * + * Contributors: + * + * Kohsuke Kawaguchi + * * *******************************************************************************/ @@ -22,16 +22,15 @@ import hudson.model.Hudson; /** * Maintains the automatically inferred {@link RepositoryBrowser} instance. * - * <p> - * To reduce the user's work, Hudson tries to infer applicable {@link RepositoryBrowser} - * from configurations of other jobs. But this needs caution — for example, - * such inferred {@link RepositoryBrowser} must be recalculated whenever - * a job configuration changes somewhere. + * <p> To reduce the user's work, Hudson tries to infer applicable + * {@link RepositoryBrowser} from configurations of other jobs. But this needs + * caution — for example, such inferred {@link RepositoryBrowser} must be + * recalculated whenever a job configuration changes somewhere. * - * <p> - * This class makes such tracking easy by hiding this logic. + * <p> This class makes such tracking easy by hiding this logic. */ final class AutoBrowserHolder { + private int cacheGeneration; private RepositoryBrowser cache; private SCM owner; @@ -42,7 +41,7 @@ final class AutoBrowserHolder { public RepositoryBrowser get() { int g = owner.getDescriptor().generation; - if(g!=cacheGeneration) { + if (g != cacheGeneration) { cacheGeneration = g; cache = infer(); } @@ -50,17 +49,16 @@ final class AutoBrowserHolder { } /** - * Picks up a {@link RepositoryBrowser} that matches the - * given {@link SCM} from existing other jobs. + * Picks up a {@link RepositoryBrowser} that matches the given {@link SCM} + * from existing other jobs. * - * @return - * null if no applicable configuration was found. + * @return null if no applicable configuration was found. */ private RepositoryBrowser infer() { - for( AbstractProject p : Hudson.getInstance().getAllItems(AbstractProject.class) ) { + for (AbstractProject p : Hudson.getInstance().getAllItems(AbstractProject.class)) { SCM scm = p.getScm(); - if (scm!=null && scm.getClass()==owner.getClass() && scm.getBrowser()!=null && - ((SCMDescriptor)scm.getDescriptor()).isBrowserReusable(scm,owner)) { + if (scm != null && scm.getClass() == owner.getClass() && scm.getBrowser() != null + && ((SCMDescriptor) scm.getDescriptor()).isBrowserReusable(scm, owner)) { return scm.getBrowser(); } } diff --git a/hudson-core/src/main/java/hudson/scm/ChangeLogAnnotator.java b/hudson-core/src/main/java/hudson/scm/ChangeLogAnnotator.java index ad7a809..30a8d7a 100644 --- a/hudson-core/src/main/java/hudson/scm/ChangeLogAnnotator.java +++ b/hudson-core/src/main/java/hudson/scm/ChangeLogAnnotator.java @@ -7,10 +7,10 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: -* -* Kohsuke Kawaguchi - * + * Contributors: + * + * Kohsuke Kawaguchi + * * *******************************************************************************/ @@ -31,52 +31,49 @@ import java.util.logging.Logger; /** * Performs mark up on changelog messages to be displayed. * - * <p> - * SCM changelog messages are usually plain text, but when we display that in Hudson, - * it is often nice to be able to put mark up on the text (for example to link to - * external issue tracking system.) + * <p> SCM changelog messages are usually plain text, but when we display that + * in Hudson, it is often nice to be able to put mark up on the text (for + * example to link to external issue tracking system.) * - * <p> - * Plugins that are interested in doing so may extend this class and put {@link Extension} on it. - * When multiple annotators are registered, their results will be combined. + * <p> Plugins that are interested in doing so may extend this class and put + * {@link Extension} on it. When multiple annotators are registered, their + * results will be combined. * * @author Kohsuke Kawaguchi * @since 1.70 */ public abstract class ChangeLogAnnotator implements ExtensionPoint { + /** * Called by Hudson to allow markups to be added to the changelog text. * - * <p> - * This method is invoked each time a page is rendered, so implementations - * of this method should not take too long to execute. Also note that - * this method may be invoked concurrently by multiple threads. + * <p> This method is invoked each time a page is rendered, so + * implementations of this method should not take too long to execute. Also + * note that this method may be invoked concurrently by multiple threads. * - * <p> - * If there's any error during the processing, it should be recorded in + * <p> If there's any error during the processing, it should be recorded in * {@link Logger} and the method should return normally. * - * @param build - * Build that owns this changelog. From here you can access broader contextual - * information, like the project, or it settings. Never null. - * @param change - * The changelog entry for which this method is adding markup. - * Never null. - * @param text - * The text and markups. Implementation of this method is expected to - * add additional annotations into this object. If other annotators - * are registered, the object may already contain some markups when this - * method is invoked. Never null. {@link MarkupText#getText()} on this instance - * will return the same string as {@link Entry#getMsgEscaped()}. + * @param build Build that owns this changelog. From here you can access + * broader contextual information, like the project, or it settings. Never + * null. + * @param change The changelog entry for which this method is adding markup. + * Never null. + * @param text The text and markups. Implementation of this method is + * expected to add additional annotations into this object. If other + * annotators are registered, the object may already contain some markups + * when this method is invoked. Never null. {@link MarkupText#getText()} on + * this instance will return the same string as + * {@link Entry#getMsgEscaped()}. */ - public abstract void annotate(AbstractBuild<?,?> build, Entry change, MarkupText text ); + public abstract void annotate(AbstractBuild<?, ?> build, Entry change, MarkupText text); /** - * Registers this annotator, so that Hudson starts using this object - * for adding markup. + * Registers this annotator, so that Hudson starts using this object for + * adding markup. * - * @deprecated as of 1.286 - * Prefer automatic registration via {@link Extension} + * @deprecated as of 1.286 Prefer automatic registration via + * {@link Extension} */ public final void register() { all().add(this); @@ -88,12 +85,11 @@ public abstract class ChangeLogAnnotator implements ExtensionPoint { public final boolean unregister() { return all().remove(this); } - /** * All registered {@link ChangeLogAnnotator}s. * - * @deprecated as of 1.286 - * Use {@link #all()} for read access, and {@link Extension} for registration. + * @deprecated as of 1.286 Use {@link #all()} for read access, and + * {@link Extension} for registration. */ public static final CopyOnWriteList<ChangeLogAnnotator> annotators = ExtensionListView.createCopyOnWriteList(ChangeLogAnnotator.class); diff --git a/hudson-core/src/main/java/hudson/scm/ChangeLogEntry.java b/hudson-core/src/main/java/hudson/scm/ChangeLogEntry.java index abe6bd7..7bf632e 100644 --- a/hudson-core/src/main/java/hudson/scm/ChangeLogEntry.java +++ b/hudson-core/src/main/java/hudson/scm/ChangeLogEntry.java @@ -7,10 +7,10 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: + * Contributors: * * Nikita Levyankov - * + * * *******************************************************************************/ @@ -20,16 +20,18 @@ import hudson.model.User; import java.util.Collection; /** - * Interface that represents entry from change log. - * Note: this interface is gonna be used in email-ext plugin and some other plugins. - * So, changing methods signatures could broke existing logic. - * <p/> + * Interface that represents entry from change log. Note: this interface is + * gonna be used in email-ext plugin and some other plugins. So, changing + * methods signatures could broke existing logic. * <p/> + * < + * p/> * Date: 5/23/11 * * @author Nikita Levyankov */ interface ChangeLogEntry { + ChangeLogSet getParent(); /** @@ -49,11 +51,10 @@ interface ChangeLogEntry { String getMsg(); /** - * Returns a set of paths in the workspace that was - * affected by this change. + * Returns a set of paths in the workspace that was affected by this change. * <p/> - * Contains string like 'foo/bar/zot'. No leading/trailing '/', - * and separator must be normalized to '/'. + * Contains string like 'foo/bar/zot'. No leading/trailing '/', and + * separator must be normalized to '/'. * * @return never null. */ @@ -74,21 +75,20 @@ interface ChangeLogEntry { String getUser(); /** - * Returns revision version. - * Some VCS's use string representation of revision number, for ex. git or cvs; - * perforce, svn - use numeric values for revisions + * Returns revision version. Some VCS's use string representation of + * revision number, for ex. git or cvs; perforce, svn - use numeric values + * for revisions * * @return revision version. */ String getCurrentRevision(); /** - * Returns a set of paths in the workspace that was - * affected by this change. + * Returns a set of paths in the workspace that was affected by this change. * <p/> * Noted: since this is a new interface, some of the SCMs may not have - * implemented this interface. The default implementation for this - * interface is throw UnsupportedOperationException + * implemented this interface. The default implementation for this interface + * is throw UnsupportedOperationException * * @return AffectedFile never null. * @since 2.0.1 diff --git a/hudson-core/src/main/java/hudson/scm/ChangeLogParser.java b/hudson-core/src/main/java/hudson/scm/ChangeLogParser.java index 9369dec..08b66c7 100644 --- a/hudson-core/src/main/java/hudson/scm/ChangeLogParser.java +++ b/hudson-core/src/main/java/hudson/scm/ChangeLogParser.java @@ -7,10 +7,10 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: -* -* Kohsuke Kawaguchi - * + * Contributors: + * + * Kohsuke Kawaguchi + * * *******************************************************************************/ @@ -27,11 +27,11 @@ import java.io.IOException; /** * Encapsulates the file format of the changelog. * - * Instances should be stateless, but - * persisted as a part of {@link Build}. + * Instances should be stateless, but persisted as a part of {@link Build}. * * @author Kohsuke Kawaguchi */ public abstract class ChangeLogParser { + public abstract ChangeLogSet<? extends Entry> parse(AbstractBuild build, File changelogFile) throws IOException, SAXException; } diff --git a/hudson-core/src/main/java/hudson/scm/ChangeLogSet.java b/hudson-core/src/main/java/hudson/scm/ChangeLogSet.java index c8e1292..05ae37c 100644 --- a/hudson-core/src/main/java/hudson/scm/ChangeLogSet.java +++ b/hudson-core/src/main/java/hudson/scm/ChangeLogSet.java @@ -7,10 +7,10 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: + * Contributors: * * Kohsuke Kawaguchi, Nikita Levyankov - * + * * *******************************************************************************/ @@ -31,12 +31,14 @@ import org.kohsuke.stapler.export.ExportedBean; /** * Represents SCM change list. * <p/> + * < + * p/> + * Use the "index" view of this object to render the changeset detail page, and + * use the "digest" view of this object to render the summary page. For the + * change list at project level, see {@link SCM}. * <p/> - * Use the "index" view of this object to render the changeset detail page, - * and use the "digest" view of this object to render the summary page. - * For the change list at project level, see {@link SCM}. - * <p/> - * <p/> + * < + * p/> * {@link Iterator} is expected to return recent changes first. * * @author Kohsuke Kawaguchi @@ -62,7 +64,7 @@ public abstract class ChangeLogSet<T extends ChangeLogSet.Entry> implements Iter /** * Returns true if there's no change. * - * @return if {@link #getLogs()} returns empty or null list + * @return if {@link #getLogs()} returns empty or null list */ public boolean isEmptySet() { return CollectionUtils.isEmpty(getLogs()); @@ -73,7 +75,7 @@ public abstract class ChangeLogSet<T extends ChangeLogSet.Entry> implements Iter */ @SuppressWarnings("unchecked") public Iterator<T> iterator() { - return isEmptySet()? Iterators.<T>emptyIterator(): getLogs().iterator(); + return isEmptySet() ? Iterators.<T>emptyIterator() : getLogs().iterator(); } /** @@ -83,13 +85,15 @@ public abstract class ChangeLogSet<T extends ChangeLogSet.Entry> implements Iter @Exported public final Object[] getItems() { List<T> r = new ArrayList<T>(); - for (T t : this) + for (T t : this) { r.add(t); + } return r.toArray(); } /** * Optional identification of the kind of SCM being used. + * * @return a short token, such as the SCM's main CLI executable name * @since 1.284 */ @@ -114,6 +118,7 @@ public abstract class ChangeLogSet<T extends ChangeLogSet.Entry> implements Iter @ExportedBean(defaultVisibility = 999) public static abstract class Entry implements ChangeLogEntry { + private ChangeLogSet parent; public ChangeLogSet getParent() { @@ -128,14 +133,11 @@ public abstract class ChangeLogSet<T extends ChangeLogSet.Entry> implements Iter } /** - * Returns a set of paths in the workspace that was - * affected by this change. - * <p> - * Noted: since this is a new interface, some of the SCMs may not have - * implemented this interface. The default implementation for this - * interface is throw UnsupportedOperationException - * <p> - * It doesn't throw NoSuchMethodException because I rather to throw a + * Returns a set of paths in the workspace that was affected by this + * change. <p> Noted: since this is a new interface, some of the SCMs + * may not have implemented this interface. The default implementation + * for this interface is throw UnsupportedOperationException <p> It + * doesn't throw NoSuchMethodException because I rather to throw a * runtime exception * * @return AffectedFile never null. @@ -143,7 +145,7 @@ public abstract class ChangeLogSet<T extends ChangeLogSet.Entry> implements Iter */ public Collection<? extends AffectedFile> getAffectedFiles() { String scm = getScmKind(); - throw new UnsupportedOperationException("getAffectedFiles() is not implemented by " + scm); + throw new UnsupportedOperationException("getAffectedFiles() is not implemented by " + scm); } /** @@ -151,8 +153,9 @@ public abstract class ChangeLogSet<T extends ChangeLogSet.Entry> implements Iter */ public String getMsgAnnotated() { MarkupText markup = new MarkupText(getMsg()); - for (ChangeLogAnnotator a : ChangeLogAnnotator.all()) - a.annotate(parent.build,this,markup); + for (ChangeLogAnnotator a : ChangeLogAnnotator.all()) { + a.annotate(parent.build, this, markup); + } return markup.toString(false); } @@ -173,8 +176,8 @@ public abstract class ChangeLogSet<T extends ChangeLogSet.Entry> implements Iter } /** - * Returns scm name. - * Help method used for throwing exception while executing unimplemented method. + * Returns scm name. Help method used for throwing exception while + * executing unimplemented method. * * @return name. */ @@ -194,17 +197,17 @@ public abstract class ChangeLogSet<T extends ChangeLogSet.Entry> implements Iter /** * Represents a file change. Contains filename, edit type, etc. * - * I checked the API names against some some major SCMs and most SCMs - * can adapt to this interface with very little changes + * I checked the API names against some some major SCMs and most SCMs can + * adapt to this interface with very little changes * * @see ChangeLogSet.Entry#getAffectedFiles() */ public interface AffectedFile { + /** - * The path in the workspace that was affected - * <p> - * Contains string like 'foo/bar/zot'. No leading/trailing '/', - * and separator must be normalized to '/'. + * The path in the workspace that was affected <p> Contains string like + * 'foo/bar/zot'. No leading/trailing '/', and separator must be + * normalized to '/'. * * @return never null. */ diff --git a/hudson-core/src/main/java/hudson/scm/EditType.java b/hudson-core/src/main/java/hudson/scm/EditType.java index 41b166d..e596f50 100644 --- a/hudson-core/src/main/java/hudson/scm/EditType.java +++ b/hudson-core/src/main/java/hudson/scm/EditType.java @@ -7,10 +7,10 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: -* -* Kohsuke Kawaguchi - * + * Contributors: + * + * Kohsuke Kawaguchi + * * *******************************************************************************/ @@ -28,6 +28,7 @@ import java.util.Arrays; * @author Kohsuke Kawaguchi */ public final class EditType implements CustomExportedBean { + private String name; private String description; @@ -47,10 +48,8 @@ public final class EditType implements CustomExportedBean { public String toExportedObject() { return name; } - - public static final EditType ADD = new EditType("add","The file was added"); - public static final EditType EDIT = new EditType("edit","The file was modified"); - public static final EditType DELETE = new EditType("delete","The file was removed"); - - public static final List<EditType> ALL = Collections.unmodifiableList(Arrays.asList(ADD,EDIT,DELETE)); + public static final EditType ADD = new EditType("add", "The file was added"); + public static final EditType EDIT = new EditType("edit", "The file was modified"); + public static final EditType DELETE = new EditType("delete", "The file was removed"); + public static final List<EditType> ALL = Collections.unmodifiableList(Arrays.asList(ADD, EDIT, DELETE)); } diff --git a/hudson-core/src/main/java/hudson/scm/EmptyChangeLogSet.java b/hudson-core/src/main/java/hudson/scm/EmptyChangeLogSet.java index bcdabe3..1aa55a9 100644 --- a/hudson-core/src/main/java/hudson/scm/EmptyChangeLogSet.java +++ b/hudson-core/src/main/java/hudson/scm/EmptyChangeLogSet.java @@ -7,10 +7,10 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: + * Contributors: * * Kohsuke Kawaguchi, Nikita Levyankov - * + * * *******************************************************************************/ diff --git a/hudson-core/src/main/java/hudson/scm/NullChangeLogParser.java b/hudson-core/src/main/java/hudson/scm/NullChangeLogParser.java index 0566fa4..812b79a 100644 --- a/hudson-core/src/main/java/hudson/scm/NullChangeLogParser.java +++ b/hudson-core/src/main/java/hudson/scm/NullChangeLogParser.java @@ -7,10 +7,10 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: -* -* Kohsuke Kawaguchi - * + * Contributors: + * + * Kohsuke Kawaguchi + * * *******************************************************************************/ @@ -24,9 +24,11 @@ import java.io.IOException; /** * {@link ChangeLogParser} for no SCM. + * * @author Kohsuke Kawaguchi */ public class NullChangeLogParser extends ChangeLogParser { + public ChangeLogSet<? extends ChangeLogSet.Entry> parse(AbstractBuild build, File changelogFile) throws IOException, SAXException { return ChangeLogSet.createEmpty(build); } diff --git a/hudson-core/src/main/java/hudson/scm/NullSCM.java b/hudson-core/src/main/java/hudson/scm/NullSCM.java index a85d638..5fe5d84 100644 --- a/hudson-core/src/main/java/hudson/scm/NullSCM.java +++ b/hudson-core/src/main/java/hudson/scm/NullSCM.java @@ -7,10 +7,10 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: -* -* Kohsuke Kawaguchi - * + * Contributors: + * + * Kohsuke Kawaguchi + * * *******************************************************************************/ @@ -35,6 +35,7 @@ import java.io.IOException; * @author Kohsuke Kawaguchi */ public class NullSCM extends SCM { + public SCMRevisionState calcRevisionsFromBuild(AbstractBuild<?, ?> build, Launcher launcher, TaskListener listener) throws IOException, InterruptedException { return null; } @@ -43,7 +44,7 @@ public class NullSCM extends SCM { return PollingResult.NO_CHANGES; } - public boolean checkout(AbstractBuild<?,?> build, Launcher launcher, FilePath remoteDir, BuildListener listener, File changeLogFile) throws IOException, InterruptedException { + public boolean checkout(AbstractBuild<?, ?> build, Launcher launcher, FilePath remoteDir, BuildListener listener, File changeLogFile) throws IOException, InterruptedException { return createEmptyChangeLog(changeLogFile, listener, "log"); } @@ -53,6 +54,7 @@ public class NullSCM extends SCM { @Extension public static class DescriptorImpl extends SCMDescriptor<NullSCM> { + public DescriptorImpl() { super(null); } diff --git a/hudson-core/src/main/java/hudson/scm/PollingResult.java b/hudson-core/src/main/java/hudson/scm/PollingResult.java index ffd4d57..3060ef5 100644 --- a/hudson-core/src/main/java/hudson/scm/PollingResult.java +++ b/hudson-core/src/main/java/hudson/scm/PollingResult.java @@ -8,7 +8,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * + * * *******************************************************************************/ @@ -17,38 +17,36 @@ package hudson.scm; import java.io.Serializable; /** - * Immutable object that represents the result of {@linkplain SCM#poll(hudson.model.AbstractProject, hudson.Launcher, hudson.FilePath, hudson.model.TaskListener, SCMRevisionState) SCM polling}. + * Immutable object that represents the result of + * {@linkplain SCM#poll(hudson.model.AbstractProject, hudson.Launcher, hudson.FilePath, hudson.model.TaskListener, SCMRevisionState) SCM polling}. * - * <p> - * This object is marked serializable just to be remoting friendly — Hudson by itself - * doesn't persist this object. + * <p> This object is marked serializable just to be remoting friendly — + * Hudson by itself doesn't persist this object. * * @author Kohsuke Kawaguchi * @since 1.345 */ public final class PollingResult implements Serializable { + /** - * Baseline of the comparison. - * (This comes from either the workspace, or from the remote repository as of the last polling. - * Can be null. + * Baseline of the comparison. (This comes from either the workspace, or + * from the remote repository as of the last polling. Can be null. */ //TODO: review and check whether we can do it private public final SCMRevisionState baseline; - /** - * Current state of the remote repository. To be passed to the next invocation of the polling method. - * Can be null. + * Current state of the remote repository. To be passed to the next + * invocation of the polling method. Can be null. */ //TODO: review and check whether we can do it private public final SCMRevisionState remote; - /** - * Degree of the change between baseline and remote. Never null. - * <p> - * The fact that this field is independent from {@link #baseline} and {@link #remote} are - * used to (1) allow the {@linkplain Change#INCOMPARABLE incomparable} state which forces - * the immediate rebuild, and (2) allow SCM to ignore some changes in the repository to implement - * exclusion feature. + * Degree of the change between baseline and remote. Never null. <p> The + * fact that this field is independent from {@link #baseline} and + * {@link #remote} are used to (1) allow the + * {@linkplain Change#INCOMPARABLE incomparable} state which forces the + * immediate rebuild, and (2) allow SCM to ignore some changes in the + * repository to implement exclusion feature. */ //TODO: review and check whether we can do it private public final Change change; @@ -57,47 +55,52 @@ public final class PollingResult implements Serializable { * Degree of changes between the previous state and this state. */ public enum Change { + /** - * No change. Two {@link SCMRevisionState}s point to the same state of the same repository / the same commit. + * No change. Two {@link SCMRevisionState}s point to the same state of + * the same repository / the same commit. */ NONE, /** - * There are some changes between states, but those changes are not significant enough to consider - * a new build. For example, some SCMs allow certain commits to be marked as excluded, and this is how - * you can do it. + * There are some changes between states, but those changes are not + * significant enough to consider a new build. For example, some SCMs + * allow certain commits to be marked as excluded, and this is how you + * can do it. */ INSIGNIFICANT, /** - * There are changes between states that warrant a new build. Hudson will eventually - * schedule a new build for this change, subject to other considerations - * such as the quiet period. + * There are changes between states that warrant a new build. Hudson + * will eventually schedule a new build for this change, subject to + * other considerations such as the quiet period. */ SIGNIFICANT, /** - * The state as of baseline is so different from the current state that they are incomparable - * (for example, the workspace and the remote repository points to two unrelated repositories - * because the configuration has changed.) This forces Hudson to schedule a build right away. - * <p> - * This is primarily useful in SCM implementations that require a workspace to be able - * to perform a polling. SCMs that can always compare remote revisions regardless of the local - * state should do so, and never return this constant, to let Hudson maintain the quiet period - * behavior all the time. - * <p> - * This constant is not to be confused with the errors encountered during polling, which - * should result in an exception and eventual retry by Hudson. + * The state as of baseline is so different from the current state that + * they are incomparable (for example, the workspace and the remote + * repository points to two unrelated repositories because the + * configuration has changed.) This forces Hudson to schedule a build + * right away. <p> This is primarily useful in SCM implementations that + * require a workspace to be able to perform a polling. SCMs that can + * always compare remote revisions regardless of the local state should + * do so, and never return this constant, to let Hudson maintain the + * quiet period behavior all the time. <p> This constant is not to be + * confused with the errors encountered during polling, which should + * result in an exception and eventual retry by Hudson. */ INCOMPARABLE } public PollingResult(SCMRevisionState baseline, SCMRevisionState remote, Change change) { - if (change==null) throw new IllegalArgumentException(); + if (change == null) { + throw new IllegalArgumentException(); + } this.baseline = baseline; this.remote = remote; this.change = change; } public PollingResult(Change change) { - this(null,null,change); + this(null, null, change); } public SCMRevisionState getBaseline() { @@ -115,18 +118,15 @@ public final class PollingResult implements Serializable { public boolean hasChanges() { return change.ordinal() > Change.INSIGNIFICANT.ordinal(); } - /** * Constant to indicate no changes in the remote repository. */ public static final PollingResult NO_CHANGES = new PollingResult(Change.NONE); - public static final PollingResult SIGNIFICANT = new PollingResult(Change.SIGNIFICANT); - /** - * Constant that uses {@link Change#INCOMPARABLE} which forces an immediate build. + * Constant that uses {@link Change#INCOMPARABLE} which forces an immediate + * build. */ public static final PollingResult BUILD_NOW = new PollingResult(Change.INCOMPARABLE); - private static final long serialVersionUID = 1L; } diff --git a/hudson-core/src/main/java/hudson/scm/RepositoryBrowser.java b/hudson-core/src/main/java/hudson/scm/RepositoryBrowser.java index f48f218..7bbc119 100644 --- a/hudson-core/src/main/java/hudson/scm/RepositoryBrowser.java +++ b/hudson-core/src/main/java/hudson/scm/RepositoryBrowser.java @@ -7,10 +7,10 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: -* -* Kohsuke Kawaguchi - * + * Contributors: + * + * Kohsuke Kawaguchi + * * *******************************************************************************/ @@ -30,19 +30,17 @@ import java.net.MalformedURLException; import org.kohsuke.stapler.export.ExportedBean; /** - * Connects Hudson to repository browsers like ViewCVS or FishEye, - * so that Hudson can generate links to them. + * Connects Hudson to repository browsers like ViewCVS or FishEye, so that + * Hudson can generate links to them. * - * <p> - * {@link RepositoryBrowser} instance is normally created as - * a result of job configuration, and stores immutable - * configuration information (such as the URL of the FishEye site). + * <p> {@link RepositoryBrowser} instance is normally created as a result of job + * configuration, and stores immutable configuration information (such as the + * URL of the FishEye site). * - * <p> - * {@link RepositoryBrowser} is persisted with {@link SCM}. + * <p> {@link RepositoryBrowser} is persisted with {@link SCM}. * - * <p> - * To have Hudson recognize {@link RepositoryBrowser}, put {@link Extension} on your {@link Descriptor}. + * <p> To have Hudson recognize {@link RepositoryBrowser}, put {@link Extension} + * on your {@link Descriptor}. * * @author Kohsuke Kawaguchi * @since 1.89 @@ -50,13 +48,13 @@ import org.kohsuke.stapler.export.ExportedBean; */ @ExportedBean public abstract class RepositoryBrowser<E extends ChangeLogSet.Entry> extends AbstractDescribableImpl<RepositoryBrowser<?>> implements ExtensionPoint, Serializable { + /** * Determines the link to the given change set. * - * @return - * null if this repository browser doesn't have any meaningful - * URL for a change set (for example, ViewCVS doesn't have - * any page for a change set, whereas FishEye does.) + * @return null if this repository browser doesn't have any meaningful URL + * for a change set (for example, ViewCVS doesn't have any page for a change + * set, whereas FishEye does.) */ public abstract URL getChangeSetLink(E changeSet) throws IOException; @@ -64,24 +62,26 @@ public abstract class RepositoryBrowser<E extends ChangeLogSet.Entry> extends Ab * If the given string starts with '/', return a string that removes it. */ protected static String trimHeadSlash(String s) { - if(s.startsWith("/")) return s.substring(1); + if (s.startsWith("/")) { + return s.substring(1); + } return s; } /** - * Normalize the URL so that it ends with '/'. - * <p> - * An attention is paid to preserve the query parameters in URL if any. + * Normalize the URL so that it ends with '/'. <p> An attention is paid to + * preserve the query parameters in URL if any. */ protected static URL normalizeToEndWithSlash(URL url) { - if(url.getPath().endsWith("/")) + if (url.getPath().endsWith("/")) { return url; + } // normalize String q = url.getQuery(); - q = q!=null?('?'+q):""; + q = q != null ? ('?' + q) : ""; try { - return new URL(url,url.getPath()+'/'+q); + return new URL(url, url.getPath() + '/' + q); } catch (MalformedURLException e) { // impossible throw new Error(e); @@ -91,9 +91,8 @@ public abstract class RepositoryBrowser<E extends ChangeLogSet.Entry> extends Ab /** * Returns all the registered {@link RepositoryBrowser} descriptors. */ - public static DescriptorExtensionList<RepositoryBrowser<?>,Descriptor<RepositoryBrowser<?>>> all() { - return (DescriptorExtensionList)Hudson.getInstance().getDescriptorList(RepositoryBrowser.class); + public static DescriptorExtensionList<RepositoryBrowser<?>, Descriptor<RepositoryBrowser<?>>> all() { + return (DescriptorExtensionList) Hudson.getInstance().getDescriptorList(RepositoryBrowser.class); } - private static final long serialVersionUID = 1L; } diff --git a/hudson-core/src/main/java/hudson/scm/RepositoryBrowsers.java b/hudson-core/src/main/java/hudson/scm/RepositoryBrowsers.java index 34472ed..14b3e11 100644 --- a/hudson-core/src/main/java/hudson/scm/RepositoryBrowsers.java +++ b/hudson-core/src/main/java/hudson/scm/RepositoryBrowsers.java @@ -7,10 +7,10 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: -* -* Kohsuke Kawaguchi, Daniel Dyer, Stephen Connolly - * + * Contributors: + * + * Kohsuke Kawaguchi, Daniel Dyer, Stephen Connolly + * * *******************************************************************************/ @@ -33,39 +33,43 @@ import net.sf.json.JSONObject; * @author Kohsuke Kawaguchi */ public class RepositoryBrowsers { + /** * List of all installed {@link RepositoryBrowsers}. * - * @deprecated as of 1.286. - * Use {@link RepositoryBrowser#all()} for read access and {@link Extension} for registration. + * @deprecated as of 1.286. Use {@link RepositoryBrowser#all()} for read + * access and {@link Extension} for registration. */ - public static final List<Descriptor<RepositoryBrowser<?>>> LIST = new DescriptorList<RepositoryBrowser<?>>((Class)RepositoryBrowser.class); + public static final List<Descriptor<RepositoryBrowser<?>>> LIST = new DescriptorList<RepositoryBrowser<?>>((Class) RepositoryBrowser.class); /** - * Only returns those {@link RepositoryBrowser} descriptors that extend from the given type. + * Only returns those {@link RepositoryBrowser} descriptors that extend from + * the given type. */ public static List<Descriptor<RepositoryBrowser<?>>> filter(Class<? extends RepositoryBrowser> t) { List<Descriptor<RepositoryBrowser<?>>> r = new ArrayList<Descriptor<RepositoryBrowser<?>>>(); - for (Descriptor<RepositoryBrowser<?>> d : RepositoryBrowser.all()) - if(d.isSubTypeOf(t)) + for (Descriptor<RepositoryBrowser<?>> d : RepositoryBrowser.all()) { + if (d.isSubTypeOf(t)) { r.add(d); + } + } return r; } /** * Creates an instance of {@link RepositoryBrowser} from a form submission. * - * @deprecated since 2008-06-19. - * Use {@link #createInstance(Class, StaplerRequest, JSONObject, String)}. + * @deprecated since 2008-06-19. Use + * {@link #createInstance(Class, StaplerRequest, JSONObject, String)}. */ - public static <T extends RepositoryBrowser> - T createInstance(Class<T> type, StaplerRequest req, String fieldName) throws FormException { + public static <T extends RepositoryBrowser> T createInstance(Class<T> type, StaplerRequest req, String fieldName) throws FormException { List<Descriptor<RepositoryBrowser<?>>> list = filter(type); String value = req.getParameter(fieldName); - if(value==null || value.equals("auto")) + if (value == null || value.equals("auto")) { return null; + } - return type.cast(list.get(Integer.parseInt(value)).newInstance(req,null/*TODO*/)); + return type.cast(list.get(Integer.parseInt(value)).newInstance(req, null/*TODO*/)); } /** @@ -73,11 +77,12 @@ public class RepositoryBrowsers { * * @since 1.227 */ - public static <T extends RepositoryBrowser> - T createInstance(Class<T> type, StaplerRequest req, JSONObject parent, String fieldName) throws FormException { - JSONObject o = (JSONObject)parent.get(fieldName); - if(o==null) return null; + public static <T extends RepositoryBrowser> T createInstance(Class<T> type, StaplerRequest req, JSONObject parent, String fieldName) throws FormException { + JSONObject o = (JSONObject) parent.get(fieldName); + if (o == null) { + return null; + } - return req.bindJSON(type,o); + return req.bindJSON(type, o); } } diff --git a/hudson-core/src/main/java/hudson/scm/SCM.java b/hudson-core/src/main/java/hudson/scm/SCM.java index 7c01001..d4da986 100644 --- a/hudson-core/src/main/java/hudson/scm/SCM.java +++ b/hudson-core/src/main/java/hudson/scm/SCM.java @@ -7,10 +7,10 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: -* -* Kohsuke Kawaguchi, Stephen Connolly, InfraDNA, Inc. - * + * Contributors: + * + * Kohsuke Kawaguchi, Stephen Connolly, InfraDNA, Inc. + * * *******************************************************************************/ @@ -52,26 +52,24 @@ import org.kohsuke.stapler.export.ExportedBean; /** * Captures the configuration information in it. * - * <p> - * To register a custom {@link SCM} implementation from a plugin, - * put {@link Extension} on your {@link SCMDescriptor}. + * <p> To register a custom {@link SCM} implementation from a plugin, put + * {@link Extension} on your {@link SCMDescriptor}. * - * <p> - * Use the "project-changes" view to render change list to be displayed - * at the project level. The default implementation simply aggregates - * change lists from builds, but your SCM can provide different views. - * The view gets the "builds" variable which is a list of builds that are - * selected for the display. + * <p> Use the "project-changes" view to render change list to be displayed at + * the project level. The default implementation simply aggregates change lists + * from builds, but your SCM can provide different views. The view gets the + * "builds" variable which is a list of builds that are selected for the + * display. * - * <p> - * If you are interested in writing a subclass in a plugin, - * also take a look at <a href="http://wiki.hudson-ci.org/display/HUDSON/Writing+an+SCM+plugin"> + * <p> If you are interested in writing a subclass in a plugin, also take a look + * at <a href="http://wiki.hudson-ci.org/display/HUDSON/Writing+an+SCM+plugin"> * "Writing an SCM plugin"</a> wiki article. * * @author Kohsuke Kawaguchi */ @ExportedBean public abstract class SCM implements Describable<SCM>, ExtensionPoint { + /** * Stores {@link AutoBrowserHolder}. Lazily created. */ @@ -85,12 +83,11 @@ public abstract class SCM implements Describable<SCM>, ExtensionPoint { } /** - * Returns the {@link RepositoryBrowser} for files - * controlled by this {@link SCM}. + * Returns the {@link RepositoryBrowser} for files controlled by this + * {@link SCM}. * - * @return - * null to indicate that there's no explicitly configured browser - * for this SCM instance. + * @return null to indicate that there's no explicitly configured browser + * for this SCM instance. * * @see #getEffectiveBrowser() */ @@ -109,20 +106,21 @@ public abstract class SCM implements Describable<SCM>, ExtensionPoint { } /** - * Returns the applicable {@link RepositoryBrowser} for files - * controlled by this {@link SCM}. + * Returns the applicable {@link RepositoryBrowser} for files controlled by + * this {@link SCM}. * - * <p> - * This method attempts to find applicable browser - * from other job configurations. + * <p> This method attempts to find applicable browser from other job + * configurations. */ - @Exported(name="browser") + @Exported(name = "browser") public final RepositoryBrowser<?> getEffectiveBrowser() { RepositoryBrowser<?> b = getBrowser(); - if(b!=null) + if (b != null) { return b; - if(autoBrowserHolder==null) + } + if (autoBrowserHolder == null) { autoBrowserHolder = new AutoBrowserHolder(this); + } return autoBrowserHolder.get(); } @@ -136,116 +134,117 @@ public abstract class SCM implements Describable<SCM>, ExtensionPoint { public boolean supportsPolling() { return true; } - + /** - * Returns true if this SCM requires a checked out workspace for doing polling. + * Returns true if this SCM requires a checked out workspace for doing + * polling. * - * <p> - * This flag affects the behavior of Hudson when a job lost its workspace - * (typically due to a slave outage.) If this method returns false and - * polling is configured, then that would immediately trigger a new build. + * <p> This flag affects the behavior of Hudson when a job lost its + * workspace (typically due to a slave outage.) If this method returns false + * and polling is configured, then that would immediately trigger a new + * build. * - * <p> - * This flag also affects the mutual exclusion control between builds and polling. - * If this methods returns false, polling will continu asynchronously even - * when a build is in progress, but otherwise the polling activity is blocked - * if a build is currently using a workspace. + * <p> This flag also affects the mutual exclusion control between builds + * and polling. If this methods returns false, polling will continu + * asynchronously even when a build is in progress, but otherwise the + * polling activity is blocked if a build is currently using a workspace. * - * <p> - * The default implementation returns true. + * <p> The default implementation returns true. * - * <p> - * See issue #1348 for more discussion of this feature. + * <p> See issue #1348 for more discussion of this feature. * * @since 1.196 */ public boolean requiresWorkspaceForPolling() { - return true; + return true; } /** - * Called before a workspace is deleted on the given node, to provide SCM an opportunity to perform clean up. - * - * <p> - * Hudson periodically scans through all the slaves and removes old workspaces that are deemed unnecesasry. - * This behavior is implemented in {@link WorkspaceCleanupThread}, and it is necessary to control the - * disk consumption on slaves. If we don't do this, in a long run, all the slaves will have workspaces - * for all the projects, which will be prohibitive in big Hudson. - * - * <p> - * However, some SCM implementations require that the server be made aware of deletion of the local workspace, - * and this method provides an opportunity for SCMs to perform such a clean-up act. - * - * <p> - * This call back is invoked after Hudson determines that a workspace is unnecessary, but before the actual - * recursive directory deletion happens. - * - * <p> - * Note that this method does not guarantee that such a clean up will happen. For example, slaves can be - * taken offline by being physically removed from the network, and in such a case there's no opportunity - * to perform this clean up. - * - * <p> - * This method is also invoked when the project is deleted. - * - * @param project - * The project that owns this {@link SCM}. This is always the same object for a particular instance - * of {@link SCM}. Just passed in here so that {@link SCM} itself doesn't have to remember the value. - * @param workspace - * The workspace which is about to be deleted. Never null. This can be a remote file path. - * @param node - * The node that hosts the workspace. SCM can use this information to determine the course of action. - * - * @return - * true if {@link SCM} is OK to let Hudson proceed with deleting the workspace. - * False to veto the workspace deletion. - * + * Called before a workspace is deleted on the given node, to provide SCM an + * opportunity to perform clean up. + * + * <p> Hudson periodically scans through all the slaves and removes old + * workspaces that are deemed unnecesasry. This behavior is implemented in + * {@link WorkspaceCleanupThread}, and it is necessary to control the disk + * consumption on slaves. If we don't do this, in a long run, all the slaves + * will have workspaces for all the projects, which will be prohibitive in + * big Hudson. + * + * <p> However, some SCM implementations require that the server be made + * aware of deletion of the local workspace, and this method provides an + * opportunity for SCMs to perform such a clean-up act. + * + * <p> This call back is invoked after Hudson determines that a workspace is + * unnecessary, but before the actual recursive directory deletion happens. + * + * <p> Note that this method does not guarantee that such a clean up will + * happen. For example, slaves can be taken offline by being physically + * removed from the network, and in such a case there's no opportunity to + * perform this clean up. + * + * <p> This method is also invoked when the project is deleted. + * + * @param project The project that owns this {@link SCM}. This is always the + * same object for a particular instance of {@link SCM}. Just passed in here + * so that {@link SCM} itself doesn't have to remember the value. + * @param workspace The workspace which is about to be deleted. Never null. + * This can be a remote file path. + * @param node The node that hosts the workspace. SCM can use this + * information to determine the course of action. + * + * @return true if {@link SCM} is OK to let Hudson proceed with deleting the + * workspace. False to veto the workspace deletion. + * * @since 1.246 */ - public boolean processWorkspaceBeforeDeletion(AbstractProject<?,?> project, FilePath workspace, Node node) throws IOException, InterruptedException { + public boolean processWorkspaceBeforeDeletion(AbstractProject<?, ?> project, FilePath workspace, Node node) throws IOException, InterruptedException { return true; } /** * Checks if there has been any changes to this module in the repository. * - * TODO: we need to figure out a better way to communicate an error back, - * so that we won't keep retrying the same node (for example a slave might be down.) + * TODO: we need to figure out a better way to communicate an error back, so + * that we won't keep retrying the same node (for example a slave might be + * down.) * - * <p> - * If the SCM doesn't implement polling, have the {@link #supportsPolling()} method - * return false. + * <p> If the SCM doesn't implement polling, have the + * {@link #supportsPolling()} method return false. * - * @param project - * The project to check for updates - * @param launcher - * Abstraction of the machine where the polling will take place. If SCM declares - * that {@linkplain #requiresWorkspaceForPolling() the polling doesn't require a workspace}, this parameter is null. - * @param workspace - * The workspace directory that contains baseline files. If SCM declares - * that {@linkplain #requiresWorkspaceForPolling() the polling doesn't require a workspace}, this parameter is null. - * @param listener - * Logs during the polling should be sent here. + * @param project The project to check for updates + * @param launcher Abstraction of the machine where the polling will take + * place. If SCM declares that + * {@linkplain #requiresWorkspaceForPolling() the polling doesn't require a workspace}, + * this parameter is null. + * @param workspace The workspace directory that contains baseline files. If + * SCM declares that + * {@linkplain #requiresWorkspaceForPolling() the polling doesn't require a workspace}, + * this parameter is null. + * @param listener Logs during the polling should be sent here. * - * @return true - * if the change is detected. + * @return true if the change is detected. * - * @throws InterruptedException - * interruption is usually caused by the user aborting the computation. - * this exception should be simply propagated all the way up. + * @throws InterruptedException interruption is usually caused by the user + * aborting the computation. this exception should be simply propagated all + * the way up. * * @see #supportsPolling() * - * @deprecated as of 1.345 - * Override {@link #calcRevisionsFromBuild(AbstractBuild, Launcher, TaskListener)} and - * {@link #compareRemoteRevisionWith(AbstractProject, Launcher, FilePath, TaskListener, SCMRevisionState)} for implementation. + * @deprecated as of 1.345 Override + * {@link #calcRevisionsFromBuild(AbstractBuild, Launcher, TaskListener)} + * and + * {@link #compareRemoteRevisionWith(AbstractProject, Launcher, FilePath, TaskListener, SCMRevisionState)} + * for implementation. * - * The implementation is now separated in two pieces, one that computes the revision of the current workspace, - * and the other that computes the revision of the remote repository. + * The implementation is now separated in two pieces, one that computes the + * revision of the current workspace, and the other that computes the + * revision of the remote repository. * - * Call {@link #poll(AbstractProject, Launcher, FilePath, TaskListener, SCMRevisionState)} for use instead. + * Call + * {@link #poll(AbstractProject, Launcher, FilePath, TaskListener, SCMRevisionState)} + * for use instead. */ - public boolean pollChanges(AbstractProject<?,?> project, Launcher launcher, FilePath workspace, TaskListener listener) throws IOException, InterruptedException { + public boolean pollChanges(AbstractProject<?, ?> project, Launcher launcher, FilePath workspace, TaskListener listener) throws IOException, InterruptedException { // up until 1.336, this method was abstract, so everyone should have overridden this method // without calling super.pollChanges. So the compatibility implementation is purely for // new implementations that doesn't override this method. @@ -255,108 +254,115 @@ public abstract class SCM implements Describable<SCM>, ExtensionPoint { } /** - * Calculates the {@link SCMRevisionState} that represents the state of the workspace of the given build. - * - * <p> - * The returned object is then fed into the - * {@link #compareRemoteRevisionWith(AbstractProject, Launcher, FilePath, TaskListener, SCMRevisionState)} method - * as the baseline {@link SCMRevisionState} to determine if the build is necessary. - * - * <p> - * This method is called after source code is checked out for the given build (that is, after - * {@link SCM#checkout(AbstractBuild, Launcher, FilePath, BuildListener, File)} has finished successfully.) - * - * <p> - * The obtained object is added to the build as an {@link Action} for later retrieval. As an optimization, - * {@link SCM} implementation can choose to compute {@link SCMRevisionState} and add it as an action - * during check out, in which case this method will not called. - * - * @param build - * The calculated {@link SCMRevisionState} is for the files checked out in this build. Never null. - * If {@link #requiresWorkspaceForPolling()} returns true, Hudson makes sure that the workspace of this - * build is available and accessible by the callee. - * @param launcher - * Abstraction of the machine where the polling will take place. If SCM declares - * that {@linkplain #requiresWorkspaceForPolling() the polling doesn't require a workspace}, - * this parameter is null. Otherwise never null. - * @param listener - * Logs during the polling should be sent here. + * Calculates the {@link SCMRevisionState} that represents the state of the + * workspace of the given build. + * + * <p> The returned object is then fed into the + * {@link #compareRemoteRevisionWith(AbstractProject, Launcher, FilePath, TaskListener, SCMRevisionState)} + * method as the baseline {@link SCMRevisionState} to determine if the build + * is necessary. + * + * <p> This method is called after source code is checked out for the given + * build (that is, after + * {@link SCM#checkout(AbstractBuild, Launcher, FilePath, BuildListener, File)} + * has finished successfully.) + * + * <p> The obtained object is added to the build as an {@link Action} for + * later retrieval. As an optimization, {@link SCM} implementation can + * choose to compute {@link SCMRevisionState} and add it as an action during + * check out, in which case this method will not called. + * + * @param build The calculated {@link SCMRevisionState} is for the files + * checked out in this build. Never null. If + * {@link #requiresWorkspaceForPolling()} returns true, Hudson makes sure + * that the workspace of this build is available and accessible by the + * callee. + * @param launcher Abstraction of the machine where the polling will take + * place. If SCM declares that + * {@linkplain #requiresWorkspaceForPolling() the polling doesn't require a workspace}, + * this parameter is null. Otherwise never null. + * @param listener Logs during the polling should be sent here. * * @return can be null. * - * @throws InterruptedException - * interruption is usually caused by the user aborting the computation. - * this exception should be simply propagated all the way up. + * @throws InterruptedException interruption is usually caused by the user + * aborting the computation. this exception should be simply propagated all + * the way up. */ - public abstract SCMRevisionState calcRevisionsFromBuild(AbstractBuild<?,?> build, Launcher launcher, TaskListener listener) throws IOException, InterruptedException; + public abstract SCMRevisionState calcRevisionsFromBuild(AbstractBuild<?, ?> build, Launcher launcher, TaskListener listener) throws IOException, InterruptedException; /** - * A pointless function to work around what appears to be a HotSpot problem. See HUDSON-5756 and bug 6933067 - * on BugParade for more details. + * A pointless function to work around what appears to be a HotSpot problem. + * See HUDSON-5756 and bug 6933067 on BugParade for more details. */ public SCMRevisionState _calcRevisionsFromBuild(AbstractBuild<?, ?> build, Launcher launcher, TaskListener listener) throws IOException, InterruptedException { return calcRevisionsFromBuild(build, launcher, listener); } - + /** - * Compares the current state of the remote repository against the given baseline {@link SCMRevisionState}. - * - * <p> - * Conceptually, the act of polling is to take two states of the repository and to compare them to see - * if there's any difference. In practice, however, comparing two arbitrary repository states is an expensive - * operation, so in this abstraction, we chose to mix (1) the act of building up a repository state and - * (2) the act of comparing it with the earlier state, so that SCM implementations can implement this - * more easily. - * - * <p> - * Multiple invocations of this method may happen over time to make sure that the remote repository - * is "quiet" before Hudson schedules a new build. - * - * @param project - * The project to check for updates - * @param launcher - * Abstraction of the machine where the polling will take place. If SCM declares - * that {@linkplain #requiresWorkspaceForPolling() the polling doesn't require a workspace}, this parameter is null. - * @param workspace - * The workspace directory that contains baseline files. If SCM declares - * that {@linkplain #requiresWorkspaceForPolling() the polling doesn't require a workspace}, this parameter is null. - * @param listener - * Logs during the polling should be sent here. - * @param baseline - * The baseline of the comparison. This object is the return value from earlier - * {@link #compareRemoteRevisionWith(AbstractProject, Launcher, FilePath, TaskListener, SCMRevisionState)} or - * {@link #calcRevisionsFromBuild(AbstractBuild, Launcher, TaskListener)}. - * - * @return - * This method returns multiple values that are bundled together into the {@link PollingResult} value type. - * {@link PollingResult#baseline} should be the value of the baseline parameter, {@link PollingResult#remote} - * is the current state of the remote repository (this object only needs to be understandable to the future - * invocations of this method), - * and {@link PollingResult#change} that indicates the degree of changes found during the comparison. - * - * @throws InterruptedException - * interruption is usually caused by the user aborting the computation. - * this exception should be simply propagated all the way up. + * Compares the current state of the remote repository against the given + * baseline {@link SCMRevisionState}. + * + * <p> Conceptually, the act of polling is to take two states of the + * repository and to compare them to see if there's any difference. In + * practice, however, comparing two arbitrary repository states is an + * expensive operation, so in this abstraction, we chose to mix (1) the act + * of building up a repository state and (2) the act of comparing it with + * the earlier state, so that SCM implementations can implement this more + * easily. + * + * <p> Multiple invocations of this method may happen over time to make sure + * that the remote repository is "quiet" before Hudson schedules a new + * build. + * + * @param project The project to check for updates + * @param launcher Abstraction of the machine where the polling will take + * place. If SCM declares that + * {@linkplain #requiresWorkspaceForPolling() the polling doesn't require a workspace}, + * this parameter is null. + * @param workspace The workspace directory that contains baseline files. If + * SCM declares that + * {@linkplain #requiresWorkspaceForPolling() the polling doesn't require a workspace}, + * this parameter is null. + * @param listener Logs during the polling should be sent here. + * @param baseline The baseline of the comparison. This object is the return + * value from earlier + * {@link #compareRemoteRevisionWith(AbstractProject, Launcher, FilePath, TaskListener, SCMRevisionState)} + * or + * {@link #calcRevisionsFromBuild(AbstractBuild, Launcher, TaskListener)}. + * + * @return This method returns multiple values that are bundled together + * into the {@link PollingResult} value type. {@link PollingResult#baseline} + * should be the value of the baseline parameter, + * {@link PollingResult#remote} is the current state of the remote + * repository (this object only needs to be understandable to the future + * invocations of this method), and {@link PollingResult#change} that + * indicates the degree of changes found during the comparison. + * + * @throws InterruptedException interruption is usually caused by the user + * aborting the computation. this exception should be simply propagated all + * the way up. */ - protected abstract PollingResult compareRemoteRevisionWith(AbstractProject<?,?> project, Launcher launcher, FilePath workspace, TaskListener listener, SCMRevisionState baseline) throws IOException, InterruptedException; + protected abstract PollingResult compareRemoteRevisionWith(AbstractProject<?, ?> project, Launcher launcher, FilePath workspace, TaskListener listener, SCMRevisionState baseline) throws IOException, InterruptedException; /** - * A pointless function to work around what appears to be a HotSpot problem. See HUDSON-5756 and bug 6933067 - * on BugParade for more details. + * A pointless function to work around what appears to be a HotSpot problem. + * See HUDSON-5756 and bug 6933067 on BugParade for more details. */ private PollingResult _compareRemoteRevisionWith(AbstractProject<?, ?> project, Launcher launcher, FilePath workspace, TaskListener listener, SCMRevisionState baseline2) throws IOException, InterruptedException { return compareRemoteRevisionWith(project, launcher, workspace, listener, baseline2); } /** - * Convenience method for the caller to handle the backward compatibility between pre 1.345 SCMs. + * Convenience method for the caller to handle the backward compatibility + * between pre 1.345 SCMs. */ - public final PollingResult poll(AbstractProject<?,?> project, Launcher launcher, FilePath workspace, TaskListener listener, SCMRevisionState baseline) throws IOException, InterruptedException { + public final PollingResult poll(AbstractProject<?, ?> project, Launcher launcher, FilePath workspace, TaskListener listener, SCMRevisionState baseline) throws IOException, InterruptedException { if (is1_346OrLater()) { // This is to work around HUDSON-5827 in a general way. // don't let the SCM.compareRemoteRevisionWith(...) see SCMRevisionState that it didn't produce. SCMRevisionState baseline2; - if (baseline!=SCMRevisionState.NONE) { + if (baseline != SCMRevisionState.NONE) { baseline2 = baseline; } else { baseline2 = _calcRevisionsFromBuild(project.getLastBuild(), launcher, listener); @@ -364,7 +370,7 @@ public abstract class SCM implements Describable<SCM>, ExtensionPoint { return _compareRemoteRevisionWith(project, launcher, workspace, listener, baseline2); } else { - return pollChanges(project,launcher,workspace,listener) ? PollingResult.SIGNIFICANT : PollingResult.NO_CHANGES; + return pollChanges(project, launcher, workspace, listener) ? PollingResult.SIGNIFICANT : PollingResult.NO_CHANGES; } } @@ -373,7 +379,8 @@ public abstract class SCM implements Describable<SCM>, ExtensionPoint { try { c.getDeclaredMethod("compareRemoteRevisionWith", AbstractProject.class, Launcher.class, FilePath.class, TaskListener.class, SCMRevisionState.class); return true; - } catch (NoSuchMethodException e) { } + } catch (NoSuchMethodException e) { + } } return false; } @@ -382,54 +389,49 @@ public abstract class SCM implements Describable<SCM>, ExtensionPoint { * Obtains a fresh workspace of the module(s) into the specified directory * of the specified machine. * - * <p> - * The "update" operation can be performed instead of a fresh checkout if - * feasible. - * - * <p> - * This operation should also capture the information necessary to tag the workspace later. - * - * @param launcher - * Abstracts away the machine that the files will be checked out. - * @param workspace - * a directory to check out the source code. May contain left-over - * from the previous build. - * @param changelogFile - * Upon a successful return, this file should capture the changelog. - * When there's no change, this file should contain an empty entry. - * See {@link #createEmptyChangeLog(File, BuildListener, String)}. - * @return - * false if the operation fails. The error should be reported to the listener. - * Otherwise return the changes included in this update (if this was an update.) - * - * @throws InterruptedException - * interruption is usually caused by the user aborting the build. - * this exception will cause the build to abort. + * <p> The "update" operation can be performed instead of a fresh checkout + * if feasible. + * + * <p> This operation should also capture the information necessary to tag + * the workspace later. + * + * @param launcher Abstracts away the machine that the files will be checked + * out. + * @param workspace a directory to check out the source code. May contain + * left-over from the previous build. + * @param changelogFile Upon a successful return, this file should capture + * the changelog. When there's no change, this file should contain an empty + * entry. See {@link #createEmptyChangeLog(File, BuildListener, String)}. + * @return false if the operation fails. The error should be reported to the + * listener. Otherwise return the changes included in this update (if this + * was an update.) + * + * @throws InterruptedException interruption is usually caused by the user + * aborting the build. this exception will cause the build to abort. */ - public abstract boolean checkout(AbstractBuild<?,?> build, Launcher launcher, FilePath workspace, BuildListener listener, File changelogFile) throws IOException, InterruptedException; + public abstract boolean checkout(AbstractBuild<?, ?> build, Launcher launcher, FilePath workspace, BuildListener listener, File changelogFile) throws IOException, InterruptedException; /** * Adds environmental variables for the builds to the given map. * - * <p> - * This can be used to propagate information from SCM to builds - * (for example, SVN revision number.) + * <p> This can be used to propagate information from SCM to builds (for + * example, SVN revision number.) * - * <p> - * This method is invoked whenever someone does {@link AbstractBuild#getEnvironment(TaskListener)}, which - * can be before/after your checkout method is invoked. So if you are going to provide information about - * check out (like SVN revision number that was checked out), be prepared for the possibility that the - * check out hasn't happened yet. + * <p> This method is invoked whenever someone does + * {@link AbstractBuild#getEnvironment(TaskListener)}, which can be + * before/after your checkout method is invoked. So if you are going to + * provide information about check out (like SVN revision number that was + * checked out), be prepared for the possibility that the check out hasn't + * happened yet. */ - public void buildEnvVars(AbstractBuild<?,?> build, Map<String, String> env) { + public void buildEnvVars(AbstractBuild<?, ?> build, Map<String, String> env) { // default implementation is noop. } /** * Gets the top directory of the checked out module. * - * <p> - * Often SCMs have to create a directory inside a workspace, which + * <p> Often SCMs have to create a directory inside a workspace, which * creates directory layout like this: * * <pre> @@ -439,36 +441,30 @@ public abstract class SCM implements Describable<SCM>, ExtensionPoint { * +- build.xml <- user file * </pre> * - * <p> - * Many builders, like Ant or Maven, works off the specific user file - * at the top of the checked out module (in the above case, that would - * be <tt>xyz/build.xml</tt>), yet the builder doesn't know the "xyz" - * part; that comes from SCM. - * - * <p> - * Collaboration between {@link Builder} and {@link SCM} allows - * Hudson to find build.xml wihout asking the user to enter "xyz" again. - * - * <p> - * This method is for this purpose. It takes the workspace - * root as a parameter, and expected to return the directory - * that was checked out from SCM. - * - * <p> - * If this SCM is configured to create a directory, try to - * return that directory so that builders can work seamlessly. - * - * <p> - * If SCM doesn't need to create any directory inside workspace, - * or in any other tricky cases, it should revert to the default - * implementation, which is to just return the parameter. - * - * @param workspace - * The workspace root directory. - * @param build - * The build for which the module root is desired. - * This parameter is null when existing legacy code calls deprecated {@link #getModuleRoot(FilePath)}. - * Handle this situation gracefully if your can, but otherwise you can just fail with an exception, too. + * <p> Many builders, like Ant or Maven, works off the specific user file at + * the top of the checked out module (in the above case, that would be + * <tt>xyz/build.xml</tt>), yet the builder doesn't know the "xyz" part; + * that comes from SCM. + * + * <p> Collaboration between {@link Builder} and {@link SCM} allows Hudson + * to find build.xml wihout asking the user to enter "xyz" again. + * + * <p> This method is for this purpose. It takes the workspace root as a + * parameter, and expected to return the directory that was checked out from + * SCM. + * + * <p> If this SCM is configured to create a directory, try to return that + * directory so that builders can work seamlessly. + * + * <p> If SCM doesn't need to create any directory inside workspace, or in + * any other tricky cases, it should revert to the default implementation, + * which is to just return the parameter. + * + * @param workspace The workspace root directory. + * @param build The build for which the module root is desired. This + * parameter is null when existing legacy code calls deprecated + * {@link #getModuleRoot(FilePath)}. Handle this situation gracefully if + * your can, but otherwise you can just fail with an exception, too. * * @since 1.382 */ @@ -476,15 +472,16 @@ public abstract class SCM implements Describable<SCM>, ExtensionPoint { // For backwards compatibility, call the one argument version of the method. return getModuleRoot(workspace); } - + /** - * @deprecated since 1.382 - * Use/override {@link #getModuleRoot(FilePath, AbstractBuild)} instead. + * @deprecated since 1.382 Use/override + * {@link #getModuleRoot(FilePath, AbstractBuild)} instead. */ public FilePath getModuleRoot(FilePath workspace) { - if (Util.isOverridden(SCM.class,getClass(),"getModuleRoot", FilePath.class,AbstractBuild.class)) - // if the subtype already implements newer getModuleRoot(FilePath,AbstractBuild), call that. - return getModuleRoot(workspace,null); + if (Util.isOverridden(SCM.class, getClass(), "getModuleRoot", FilePath.class, AbstractBuild.class)) // if the subtype already implements newer getModuleRoot(FilePath,AbstractBuild), call that. + { + return getModuleRoot(workspace, null); + } return workspace; } @@ -492,9 +489,8 @@ public abstract class SCM implements Describable<SCM>, ExtensionPoint { /** * Gets the top directories of all the checked out modules. * - * <p> - * Some SCMs support checking out multiple modules inside a workspace, which - * creates directory layout like this: + * <p> Some SCMs support checking out multiple modules inside a workspace, + * which creates directory layout like this: * * <pre> * workspace <- workspace root @@ -506,42 +502,44 @@ public abstract class SCM implements Describable<SCM>, ExtensionPoint { * +- build.xml <- user file * </pre> * - * This method takes the workspace root as a parameter, and is expected to return - * all the module roots that were checked out from SCM. + * This method takes the workspace root as a parameter, and is expected to + * return all the module roots that were checked out from SCM. * - * <p> - * For normal SCMs, the array will be of length <code>1</code> and it's contents - * will be identical to calling {@link #getModuleRoot(FilePath, AbstractBuild)}. + * <p> For normal SCMs, the array will be of length + * <code>1</code> and it's contents will be identical to calling + * {@link #getModuleRoot(FilePath, AbstractBuild)}. * * @param workspace The workspace root directory - * @param build - * The build for which the module roots are desired. - * This parameter is null when existing legacy code calls deprecated {@link #getModuleRoot(FilePath)}. - * Handle this situation gracefully if your can, but otherwise you can just fail with an exception, too. + * @param build The build for which the module roots are desired. This + * parameter is null when existing legacy code calls deprecated + * {@link #getModuleRoot(FilePath)}. Handle this situation gracefully if + * your can, but otherwise you can just fail with an exception, too. * * @return An array of all module roots. * @since 1.382 */ public FilePath[] getModuleRoots(FilePath workspace, AbstractBuild build) { - if (Util.isOverridden(SCM.class,getClass(),"getModuleRoots", FilePath.class)) - // if the subtype derives legacy getModuleRoots(FilePath), delegate to it + if (Util.isOverridden(SCM.class, getClass(), "getModuleRoots", FilePath.class)) // if the subtype derives legacy getModuleRoots(FilePath), delegate to it + { return getModuleRoots(workspace); + } // otherwise the default implementation - return new FilePath[]{getModuleRoot(workspace,build)}; + return new FilePath[]{getModuleRoot(workspace, build)}; } - + /** - * @deprecated as of 1.382. - * Use/derive from {@link #getModuleRoots(FilePath, AbstractBuild)} instead. + * @deprecated as of 1.382. Use/derive from + * {@link #getModuleRoots(FilePath, AbstractBuild)} instead. */ public FilePath[] getModuleRoots(FilePath workspace) { - if (Util.isOverridden(SCM.class,getClass(),"getModuleRoots", FilePath.class, AbstractBuild.class)) - // if the subtype already derives newer getModuleRoots(FilePath,AbstractBuild), delegate to it - return getModuleRoots(workspace,null); + if (Util.isOverridden(SCM.class, getClass(), "getModuleRoots", FilePath.class, AbstractBuild.class)) // if the subtype already derives newer getModuleRoots(FilePath,AbstractBuild), delegate to it + { + return getModuleRoots(workspace, null); + } // otherwise the default implementation - return new FilePath[] { getModuleRoot(workspace), }; + return new FilePath[]{getModuleRoot(workspace),}; } /** @@ -550,18 +548,17 @@ public abstract class SCM implements Describable<SCM>, ExtensionPoint { public abstract ChangeLogParser createChangeLogParser(); public SCMDescriptor<?> getDescriptor() { - return (SCMDescriptor)Hudson.getInstance().getDescriptorOrDie(getClass()); + return (SCMDescriptor) Hudson.getInstance().getDescriptorOrDie(getClass()); } // // convenience methods // - protected final boolean createEmptyChangeLog(File changelogFile, BuildListener listener, String rootTag) { FileWriter w = null; try { w = new FileWriter(changelogFile); - w.write("<"+rootTag +"/>"); + w.write("<" + rootTag + "/>"); w.close(); return true; } catch (IOException e) { @@ -573,39 +570,50 @@ public abstract class SCM implements Describable<SCM>, ExtensionPoint { } protected final String nullify(String s) { - if(s==null) return null; - if(s.trim().length()==0) return null; + if (s == null) { + return null; + } + if (s.trim().length() == 0) { + return null; + } return s; } - public static final PermissionGroup PERMISSIONS = new PermissionGroup(SCM.class, Messages._SCM_Permissions_Title()); /** * Permission to create new tags. + * * @since 1.171 */ - public static final Permission TAG = new Permission(PERMISSIONS,"Tag",Messages._SCM_TagPermission_Description(),Permission.CREATE); + public static final Permission TAG = new Permission(PERMISSIONS, "Tag", Messages._SCM_TagPermission_Description(), Permission.CREATE); /** * Returns all the registered {@link SCMDescriptor}s. */ - public static DescriptorExtensionList<SCM,SCMDescriptor<?>> all() { - return Hudson.getInstance().<SCM,SCMDescriptor<?>>getDescriptorList(SCM.class); + public static DescriptorExtensionList<SCM, SCMDescriptor<?>> all() { + return Hudson.getInstance().<SCM, SCMDescriptor<?>>getDescriptorList(SCM.class); } /** - * Returns the list of {@link SCMDescriptor}s that are applicable to the given project. + * Returns the list of {@link SCMDescriptor}s that are applicable to the + * given project. */ public static List<SCMDescriptor<?>> _for(final AbstractProject project) { - if(project==null) return all(); - + if (project == null) { + return all(); + } + final Descriptor pd = Hudson.getInstance().getDescriptor((Class) project.getClass()); List<SCMDescriptor<?>> r = new ArrayList<SCMDescriptor<?>>(); for (SCMDescriptor<?> scmDescriptor : all()) { - if(!scmDescriptor.isApplicable(project)) continue; + if (!scmDescriptor.isApplicable(project)) { + continue; + } if (pd instanceof AbstractProjectDescriptor) { AbstractProjectDescriptor apd = (AbstractProjectDescriptor) pd; - if(!apd.isApplicable(scmDescriptor)) continue; + if (!apd.isApplicable(scmDescriptor)) { + continue; + } } r.add(scmDescriptor); diff --git a/hudson-core/src/main/java/hudson/scm/SCMDescriptor.java b/hudson-core/src/main/java/hudson/scm/SCMDescriptor.java index 9931c6f..4f4e7bc 100644 --- a/hudson-core/src/main/java/hudson/scm/SCMDescriptor.java +++ b/hudson-core/src/main/java/hudson/scm/SCMDescriptor.java @@ -7,10 +7,10 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: -* -* Kohsuke Kawaguchi - * + * Contributors: + * + * Kohsuke Kawaguchi + * * *******************************************************************************/ @@ -28,23 +28,23 @@ import java.lang.reflect.Field; /** * {@link Descriptor} for {@link SCM}. * - * @param <T> - * The 'self' type that represents the type of {@link SCM} that - * this descriptor describes. + * @param <T> The 'self' type that represents the type of {@link SCM} that this + * descriptor describes. * @author Kohsuke Kawaguchi */ public abstract class SCMDescriptor<T extends SCM> extends Descriptor<SCM> { + /** - * If this SCM has corresponding {@link RepositoryBrowser}, - * that type. Otherwise this SCM will not have any repository browser. + * If this SCM has corresponding {@link RepositoryBrowser}, that type. + * Otherwise this SCM will not have any repository browser. */ public transient final Class<? extends RepositoryBrowser> repositoryBrowser; - /** - * Incremented every time a new {@link SCM} instance is created from this descriptor. - * This is used to invalidate cache. Due to the lack of synchronization and serialization, - * this field doesn't really count the # of instances created to date, - * but it's good enough for the cache invalidation. + * Incremented every time a new {@link SCM} instance is created from this + * descriptor. This is used to invalidate cache. Due to the lack of + * synchronization and serialization, this field doesn't really count the # + * of instances created to date, but it's good enough for the cache + * invalidation. */ //TODO: review and check whether we can do it private public volatile int generation = 1; @@ -56,8 +56,9 @@ public abstract class SCMDescriptor<T extends SCM> extends Descriptor<SCM> { /** * Infers the type of the corresponding {@link SCM} from the outer class. - * This version works when you follow the common convention, where a descriptor - * is written as the static nested class of the describable class. + * This version works when you follow the common convention, where a + * descriptor is written as the static nested class of the describable + * class. * * @since 1.278 */ @@ -76,15 +77,15 @@ public abstract class SCMDescriptor<T extends SCM> extends Descriptor<SCM> { public void load() { Class<? extends RepositoryBrowser> rb = repositoryBrowser; super.load(); - if (repositoryBrowser!=rb) { // XStream may overwrite even the final field. + if (repositoryBrowser != rb) { // XStream may overwrite even the final field. try { Field f = SCMDescriptor.class.getDeclaredField("repositoryBrowser"); f.setAccessible(true); - f.set(this,rb); + f.set(this, rb); } catch (NoSuchFieldException e) { - LOGGER.log(WARNING, "Failed to overwrite the repositoryBrowser field",e); + LOGGER.log(WARNING, "Failed to overwrite the repositoryBrowser field", e); } catch (IllegalAccessException e) { - LOGGER.log(WARNING, "Failed to overwrite the repositoryBrowser field",e); + LOGGER.log(WARNING, "Failed to overwrite the repositoryBrowser field", e); } } } @@ -92,24 +93,24 @@ public abstract class SCMDescriptor<T extends SCM> extends Descriptor<SCM> { /** * Optional method used by the automatic SCM browser inference. * - * <p> - * Implementing this method allows Hudson to reuse {@link RepositoryBrowser} - * configured for one project to be used for other "compatible" projects. - * - * @return - * true if the two given SCM configurations are similar enough - * that they can reuse {@link RepositoryBrowser} between them. + * <p> Implementing this method allows Hudson to reuse + * {@link RepositoryBrowser} configured for one project to be used for other + * "compatible" projects. + * + * @return true if the two given SCM configurations are similar enough that + * they can reuse {@link RepositoryBrowser} between them. */ public boolean isBrowserReusable(T x, T y) { return false; } /** - * Allows {@link SCMDescriptor}s to choose which projects it wants to be configurable against. + * Allows {@link SCMDescriptor}s to choose which projects it wants to be + * configurable against. * - * <p> - * When this method returns false, this {@link SCM} will not appear in the configuration screen - * for the given project. The default method always return true. + * <p> When this method returns false, this {@link SCM} will not appear in + * the configuration screen for the given project. The default method always + * return true. * * @since 1.294 */ @@ -118,16 +119,16 @@ public abstract class SCMDescriptor<T extends SCM> extends Descriptor<SCM> { } /** - * Returns the list of {@link RepositoryBrowser} {@link Descriptor} - * that can be used with this SCM. + * Returns the list of {@link RepositoryBrowser} {@link Descriptor} that can + * be used with this SCM. * - * @return - * can be empty but never null. + * @return can be empty but never null. */ public List<Descriptor<RepositoryBrowser<?>>> getBrowserDescriptors() { - if(repositoryBrowser==null) return Collections.emptyList(); + if (repositoryBrowser == null) { + return Collections.emptyList(); + } return RepositoryBrowsers.filter(repositoryBrowser); } - private static final Logger LOGGER = Logger.getLogger(SCMDescriptor.class.getName()); } diff --git a/hudson-core/src/main/java/hudson/scm/SCMRevisionState.java b/hudson-core/src/main/java/hudson/scm/SCMRevisionState.java index b0a5777..d184ef4 100644 --- a/hudson-core/src/main/java/hudson/scm/SCMRevisionState.java +++ b/hudson-core/src/main/java/hudson/scm/SCMRevisionState.java @@ -8,7 +8,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * + * * *******************************************************************************/ @@ -21,18 +21,19 @@ import hudson.model.Action; * used to represent the result of * {@linkplain SCM#poll(hudson.model.AbstractProject, hudson.Launcher, hudson.FilePath, hudson.model.TaskListener, SCMRevisionState) a SCM polling}. * - * <p> - * This object is used so that the successive polling can compare the tip of the repository now vs - * what it was when it was last polled. (Before 1.345, Hudson was only able to compare the tip - * of the repository vs the state of the workspace, which resulted in a problem like HUDSON-2180. + * <p> This object is used so that the successive polling can compare the tip of + * the repository now vs what it was when it was last polled. (Before 1.345, + * Hudson was only able to compare the tip of the repository vs the state of the + * workspace, which resulted in a problem like HUDSON-2180. * - * <p> - * {@link SCMRevisionState} is persisted as an action to {@link hudson.model.AbstractBuild}. + * <p> {@link SCMRevisionState} is persisted as an action to + * {@link hudson.model.AbstractBuild}. * * @author Kohsuke Kawaguchi * @since 1.345 */ public abstract class SCMRevisionState implements Action { + public String getIconFileName() { return null; } @@ -46,15 +47,15 @@ public abstract class SCMRevisionState implements Action { } /* - I can't really make this comparable because comparing two revision states often requires - non-trivial computation and conversations with the repository (mainly to figure out - which changes are insignificant and which are not.) + I can't really make this comparable because comparing two revision states often requires + non-trivial computation and conversations with the repository (mainly to figure out + which changes are insignificant and which are not.) - So instead, here we opt to a design where we tell SCM upfront about what we are comparing - against (baseline), and have it give us the new state and degree of change in PollingResult. + So instead, here we opt to a design where we tell SCM upfront about what we are comparing + against (baseline), and have it give us the new state and degree of change in PollingResult. */ - public static SCMRevisionState NONE = new None(); - private static final class None extends SCMRevisionState {} + private static final class None extends SCMRevisionState { + } } diff --git a/hudson-core/src/main/java/hudson/scm/SCMS.java b/hudson-core/src/main/java/hudson/scm/SCMS.java index c866639..32da9ff 100644 --- a/hudson-core/src/main/java/hudson/scm/SCMS.java +++ b/hudson-core/src/main/java/hudson/scm/SCMS.java @@ -7,10 +7,10 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: -* -* Kohsuke Kawaguchi - * + * Contributors: + * + * Kohsuke Kawaguchi + * * *******************************************************************************/ @@ -29,26 +29,29 @@ import javax.servlet.ServletException; /** * List of all installed SCMs. - * + * * @author Kohsuke Kawaguchi */ public class SCMS { + /** * List of all installed SCMs. - * @deprecated as of 1.286 - * Use {@link SCM#all()} for read access and {@link Extension} for registration. + * + * @deprecated as of 1.286 Use {@link SCM#all()} for read access and + * {@link Extension} for registration. */ - public static final List<SCMDescriptor<?>> SCMS = (List)new DescriptorList<SCM>(SCM.class); + public static final List<SCMDescriptor<?>> SCMS = (List) new DescriptorList<SCM>(SCM.class); /** * Parses {@link SCM} configuration from the submitted form. * - * @param target - * The project for which this SCM is configured to. + * @param target The project for which this SCM is configured to. */ public static SCM parseSCM(StaplerRequest req, AbstractProject target) throws FormException, ServletException { String scm = req.getParameter("scm"); - if(scm==null) return new NullSCM(); + if (scm == null) { + return new NullSCM(); + } int scmidx = Integer.parseInt(scm); SCMDescriptor<?> d = SCM._for(target).get(scmidx); @@ -57,11 +60,11 @@ public class SCMS { } /** - * @deprecated as of 1.294 - * Use {@link #parseSCM(StaplerRequest, AbstractProject)} and pass in the caller's project type. + * @deprecated as of 1.294 Use + * {@link #parseSCM(StaplerRequest, AbstractProject)} and pass in the + * caller's project type. */ public static SCM parseSCM(StaplerRequest req) throws FormException, ServletException { - return parseSCM(req,null); + return parseSCM(req, null); } - } diff --git a/hudson-core/src/main/java/hudson/scm/browsers/QueryBuilder.java b/hudson-core/src/main/java/hudson/scm/browsers/QueryBuilder.java index 9025824..930dc5d 100644 --- a/hudson-core/src/main/java/hudson/scm/browsers/QueryBuilder.java +++ b/hudson-core/src/main/java/hudson/scm/browsers/QueryBuilder.java @@ -7,10 +7,10 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: -* -* Kohsuke Kawaguchi - * + * Contributors: + * + * Kohsuke Kawaguchi + * * *******************************************************************************/ @@ -20,8 +20,9 @@ package hudson.scm.browsers; * Builds up a query string. * * @author Kohsuke Kawaguchi -*/ + */ public final class QueryBuilder { + private final StringBuilder buf = new StringBuilder(); public QueryBuilder(String s) { @@ -29,9 +30,14 @@ public final class QueryBuilder { } public QueryBuilder add(String s) { - if(s==null) return this; // nothing to add - if(buf.length()==0) buf.append('?'); - else buf.append('&'); + if (s == null) { + return this; // nothing to add + } + if (buf.length() == 0) { + buf.append('?'); + } else { + buf.append('&'); + } buf.append(s); return this; } diff --git a/hudson-core/src/main/java/hudson/scm/browsers/package.html b/hudson-core/src/main/java/hudson/scm/browsers/package.html index f91b585..4a51b4f 100644 --- a/hudson-core/src/main/java/hudson/scm/browsers/package.html +++ b/hudson-core/src/main/java/hudson/scm/browsers/package.html @@ -16,5 +16,5 @@ --> <html><head/><body> -Code that computes links to external source code repository browsers. -</body></html>
\ No newline at end of file + Code that computes links to external source code repository browsers. + </body></html>
\ No newline at end of file diff --git a/hudson-core/src/main/java/hudson/scm/package.html b/hudson-core/src/main/java/hudson/scm/package.html index e665694..d10c5d2 100644 --- a/hudson-core/src/main/java/hudson/scm/package.html +++ b/hudson-core/src/main/java/hudson/scm/package.html @@ -16,5 +16,5 @@ --> <html><head/><body> -Hudson's interface with source code management systems. Start with <a href="SCM.html"><tt>SCM</tt></a> -</body></html>
\ No newline at end of file + Hudson's interface with source code management systems. Start with <a href="SCM.html"><tt>SCM</tt></a> + </body></html>
\ No newline at end of file |

