Skip to content
Permalink
Browse files

[JENKINS-23365] Draft SCM-Job rework.

  • Loading branch information
jglick committed Jun 10, 2014
1 parent 09438ec commit 6a633e02bb19eba7d8d1f89f318f60e0bd76fc8e
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.509.4</version>
<version>1.568-SNAPSHOT</version>
</parent>
<artifactId>mercurial</artifactId>
<version>1.51-SNAPSHOT</version>
@@ -95,6 +95,11 @@
<artifactId>jsch</artifactId>
<version>0.1.50</version>
</dependency>
<dependency> <!-- TODO so long as we depend on a new core version, this is required to compile: -->
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>matrix-project</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>multiple-scms</artifactId>
@@ -7,9 +7,11 @@
import hudson.ExtensionPoint;
import hudson.FilePath;
import hudson.Launcher;
import hudson.Util;
import hudson.model.TaskListener;
import hudson.model.AbstractProject;
import hudson.model.Hudson;
import hudson.model.Job;
import hudson.model.Node;
import hudson.scm.PollingResult;

@@ -29,10 +31,17 @@
* Override to customize the compare functionality.
* @return either a class of change, or null if the standard comparison is wanted
*/
abstract public PollingResult.Change compare(MercurialSCM scm, Launcher launcher,
TaskListener listener, MercurialTagAction baseline,
PrintStream output, Node node, FilePath repository,
AbstractProject<?, ?> project)
throws IOException, InterruptedException;
public PollingResult.Change compare(MercurialSCM scm, Launcher launcher, TaskListener listener, MercurialTagAction baseline, PrintStream output, Node node, FilePath repository, Job<?, ?> project) throws IOException, InterruptedException {
if (Util.isOverridden(ChangeComparator.class, getClass(), "compare", MercurialSCM.class, Launcher.class, TaskListener.class, MercurialTagAction.class, PrintStream.class, Node.class, FilePath.class, AbstractProject.class) && project instanceof AbstractProject) {
return compare(scm, launcher, listener, baseline, output, node, repository, (AbstractProject) project);
} else {
throw new AbstractMethodError("you must override the new overload of compare");
}
}

@Deprecated
public PollingResult.Change compare(MercurialSCM scm, Launcher launcher, TaskListener listener, MercurialTagAction baseline, PrintStream output, Node node, FilePath repository, AbstractProject<?, ?> project) throws IOException, InterruptedException {
return compare(scm, launcher, listener, baseline, output, node, repository, (Job) project);
}

}
@@ -1,8 +1,9 @@
package hudson.plugins.mercurial;

import hudson.Util;
import hudson.model.AbstractBuild;
import hudson.model.Run;
import hudson.scm.ChangeLogParser;
import hudson.scm.RepositoryBrowser;
import hudson.util.Digester2;
import hudson.util.IOException2;

@@ -30,7 +31,7 @@ public MercurialChangeLogParser(Set<String> modules) {
this.modules = modules;
}

public MercurialChangeSetList parse(AbstractBuild build, File changelogFile)
@Override public MercurialChangeSetList parse(Run build, RepositoryBrowser<?> browser, File changelogFile)
throws IOException, SAXException {
Digester digester = new Digester2();
ArrayList<MercurialChangeSet> r = new ArrayList<MercurialChangeSet>();
@@ -91,7 +92,7 @@ public int compare(MercurialChangeSet o1, MercurialChangeSet o2) {
}
});

return new MercurialChangeSetList(build, r);
return new MercurialChangeSetList(build, browser, r);
}

}
@@ -1,7 +1,8 @@
package hudson.plugins.mercurial;

import hudson.scm.ChangeLogSet;
import hudson.model.AbstractBuild;
import hudson.model.Run;
import hudson.scm.RepositoryBrowser;

import java.util.List;
import java.util.Collections;
@@ -13,8 +14,8 @@
public class MercurialChangeSetList extends ChangeLogSet<MercurialChangeSet> {
private final List<MercurialChangeSet> changeSets;

/*package*/ MercurialChangeSetList(AbstractBuild build, List<MercurialChangeSet> logs) {
super(build);
/*package*/ MercurialChangeSetList(Run<?,?> build, RepositoryBrowser<?> browser, List<MercurialChangeSet> logs) {
super(build, browser);
Collections.reverse(logs); // put new things first
this.changeSets = Collections.unmodifiableList(logs);
for (MercurialChangeSet log : logs)
@@ -1,11 +1,11 @@
package hudson.plugins.mercurial;

import hudson.Extension;
import hudson.model.AbstractProject;
import hudson.model.Item;
import hudson.scm.SCM;
import hudson.views.ListViewColumn;
import hudson.views.ListViewColumnDescriptor;
import jenkins.triggers.SCMTriggerItem;
import org.kohsuke.stapler.DataBoundConstructor;

/**
@@ -22,15 +22,22 @@ public MercurialRevisionColumn() {
}

public String getMercurialRevision(final Item item) {
if (!AbstractProject.class.isAssignableFrom(item.getClass())) {
return "";
}
final SCM scm = ((AbstractProject) item).getScm();
if (scm == null || !MercurialSCM.class.isAssignableFrom(scm.getClass())) {
return "";
}

return ((MercurialSCM) scm).getRevision();
SCMTriggerItem s = SCMTriggerItem.SCMTriggerItems.asSCMTriggerItem(item);
if (s == null) {
return "";
}
String revision = null;
for (SCM scm : s.getSCMs()) {
if (!(scm instanceof MercurialSCM)) {
return "";
}
String _revision = ((MercurialSCM) scm).getRevision();
if (revision != null && !revision.equals(_revision)) {
return "";
}
revision = _revision;
}
return revision != null ? revision : "";
}

@Extension public static class DescriptorImpl extends ListViewColumnDescriptor {

0 comments on commit 6a633e0

Please sign in to comment.
You can’t perform that action at this time.