Skip to content
Permalink
Browse files

Merge pull request #105 from stephenc/jenkins-43507

[JENKINS-43507] Pick up new releases
  • Loading branch information...
stephenc committed Jul 5, 2017
2 parents 8e0581a + b703847 commit f172e22494279f88bc633047c4606ff777677500
Showing with 12 additions and 20 deletions.
  1. +2 −2 pom.xml
  2. +10 −18 src/main/java/hudson/plugins/mercurial/MercurialSCMSource.java
@@ -16,7 +16,7 @@
<properties>
<jenkins.version>1.642.3</jenkins.version>
<no-test-jar>false</no-test-jar>
<scm-api-plugin.version>2.2.0-alpha-1</scm-api-plugin.version>
<scm-api-plugin.version>2.2.0-beta-1</scm-api-plugin.version>
</properties>

<developers>
@@ -128,7 +128,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>branch-api</artifactId>
<version>2.0.11-alpha-1</version>
<version>2.0.11-beta-1</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -12,7 +12,6 @@
import hudson.FilePath;
import hudson.Launcher;
import hudson.RestrictedSince;
import hudson.Util;
import hudson.model.Action;
import hudson.model.Descriptor;
import hudson.model.Item;
@@ -53,11 +52,11 @@
import jenkins.scm.api.trait.SCMSourceRequest;
import jenkins.scm.api.trait.SCMSourceTrait;
import jenkins.scm.api.trait.SCMSourceTraitDescriptor;
import jenkins.scm.api.trait.SCMTrait;
import jenkins.scm.api.trait.SCMTraitDescriptor;
import jenkins.scm.impl.form.NamedArrayList;
import jenkins.scm.impl.trait.Discovery;
import jenkins.scm.impl.trait.RegexSCMHeadFilterTrait;
import jenkins.scm.impl.trait.RegexSCMSourceFilterTrait;
import jenkins.scm.impl.trait.Selection;
import org.apache.commons.lang.StringUtils;
import org.kohsuke.accmod.Restricted;
@@ -99,7 +98,7 @@ public MercurialSCMSource(String id, String source) {
super(id);
this.source = source;
this.credentialsId = credentialsId;
this.traits = new ArrayList<>();
List<SCMSourceTrait> traits = new ArrayList<>();
if (StringUtils.isNotBlank(branchPattern) && !".*".equals(branchPattern) && !".+".equals(branchPattern)) {
traits.add(new RegexSCMHeadFilterTrait(branchPattern));
}
@@ -112,12 +111,13 @@ public MercurialSCMSource(String id, String source) {
if (browser != null) {
traits.add(new MercurialBrowserSCMSourceTrait(browser));
}
this.traits = SCMTrait.asSetList(traits);
}

@SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE")
@SuppressWarnings({"deprecation", "ConstantConditions"}) private Object readResolve() throws ObjectStreamException {
if (traits == null) {
traits = new ArrayList<>();
List<SCMSourceTrait> traits = new ArrayList<>();
if (branchPattern != null) {
if (StringUtils.isNotBlank(branchPattern) && !".*".equals(branchPattern) && !".+"
.equals(branchPattern)) {
@@ -133,6 +133,7 @@ public MercurialSCMSource(String id, String source) {
if (browser != null) {
traits.add(new MercurialBrowserSCMSourceTrait(browser));
}
setTraits(traits);
}
return this;
}
@@ -155,16 +156,16 @@ public void setCredentialsId(@CheckForNull String credentialsId) {
}

@DataBoundSetter public void setTraits(@CheckForNull List<SCMSourceTrait> traits) {
this.traits = new ArrayList<>(Util.fixNull(traits));
this.traits = SCMTrait.asSetList(traits);
}

@Deprecated @Restricted(DoNotUse.class) @RestrictedSince("2.0") public String getInstallation() {
MercurialInstallationSCMSourceTrait t = getTrait(MercurialInstallationSCMSourceTrait.class);
MercurialInstallationSCMSourceTrait t = SCMTrait.find(traits, MercurialInstallationSCMSourceTrait.class);
return t != null ? t.getInstallation() : null;
}

@Deprecated @Restricted(DoNotUse.class) @RestrictedSince("2.0") public String getBranchPattern() {
RegexSCMHeadFilterTrait t = getTrait(RegexSCMHeadFilterTrait.class);
RegexSCMHeadFilterTrait t = SCMTrait.find(traits, RegexSCMHeadFilterTrait.class);
return t != null ? t.getRegex() : "";
}

@@ -177,21 +178,12 @@ public void setCredentialsId(@CheckForNull String credentialsId) {
}

@Deprecated @Restricted(DoNotUse.class) @RestrictedSince("2.0") public HgBrowser getBrowser() {
MercurialBrowserSCMSourceTrait t = getTrait(MercurialBrowserSCMSourceTrait.class);
MercurialBrowserSCMSourceTrait t = SCMTrait.find(traits, MercurialBrowserSCMSourceTrait.class);
return t != null ? t.getBrowser() : null;
}

@Deprecated @Restricted(DoNotUse.class) @RestrictedSince("2.0") public boolean isClean() {
return getTrait(CleanMercurialSCMSourceTrait.class) != null;
}

private @CheckForNull <T extends SCMSourceTrait> T getTrait(@Nonnull Class<T> traitClass) {
for (SCMSourceTrait t: traits) {
if (traitClass.isInstance(t)) {
return traitClass.cast(t);
}
}
return null;
return SCMTrait.find(traits, CleanMercurialSCMSourceTrait.class) != null;
}

@Override protected void retrieve(@CheckForNull SCMSourceCriteria criteria, @Nonnull SCMHeadObserver observer,

0 comments on commit f172e22

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