Skip to content

Commit

Permalink
[FIXED JENKINS-19649] viewmask config fix
Browse files Browse the repository at this point in the history
fixed condition for using the view mask for changelog
fixed issue where view mask for changelog option could be enabled when loading config
added test for optional configuration sections
  • Loading branch information
rpetti committed Feb 16, 2014
1 parent 4663c3c commit ea1acb1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/main/java/hudson/plugins/perforce/PerforceSCM.java
Expand Up @@ -331,7 +331,7 @@ public PerforceSCM(
MaskViewConfig useViewMask
) {

this.configVersion = 1L;
this.configVersion = 2L;

this.p4User = p4User;
this.setP4Passwd(p4Passwd);
Expand Down Expand Up @@ -651,6 +651,8 @@ public Object readResolve() {

if (configVersion == 1L) {
this.useViewMaskForChangeLog = this.useViewMaskForSyncing;

configVersion = 2L;
}

return this;
Expand Down Expand Up @@ -1054,7 +1056,7 @@ public boolean checkout(AbstractBuild build, Launcher launcher,
}

List<Integer> changeNumbersTo;
if (useViewMaskForChangeLog) {
if (useViewMaskForChangeLog && useViewMask) {
changeNumbersTo = depot.getChanges().getChangeNumbersInRange(p4workspace, lastChangeToDisplay, newestChange, viewMask, showIntegChanges);
} else {
changeNumbersTo = depot.getChanges().getChangeNumbersInRange(p4workspace, lastChangeToDisplay, newestChange, showIntegChanges);
Expand Down
6 changes: 5 additions & 1 deletion src/test/java/hudson/plugins/perforce/PerforceSCMTest.java
Expand Up @@ -5,6 +5,7 @@
import hudson.model.Hudson;
import hudson.plugins.perforce.PerforceToolInstallation.DescriptorImpl;
import hudson.plugins.perforce.browsers.P4Web;
import hudson.plugins.perforce.config.CleanTypeConfig;
import hudson.plugins.perforce.config.MaskViewConfig;
import hudson.plugins.perforce.config.WorkspaceCleanupConfig;
import hudson.tools.ToolProperty;
Expand All @@ -23,8 +24,11 @@
public class PerforceSCMTest extends HudsonTestCase {
/// Preserves original behavior of the tests
public static final DepotType EMPTY_DEPOT = null;
public static final DepotType TEST_DEPOT = new DepotType(DepotType.USE_PROJECTPATH_MARKER, null, null, "//...");
public static final MaskViewConfig EMPTY_MASKVIEW = null;
public static final MaskViewConfig TEST_MASKVIEW = new MaskViewConfig("//...", true, false, false);
public static final WorkspaceCleanupConfig EMPTY_WORKSPACE_CLEANUP = null;
public static final WorkspaceCleanupConfig TEST_WORKSPACE_CLEANUP = new WorkspaceCleanupConfig(new CleanTypeConfig("quick", true), true);

/**
* Makes sure that the configuration survives the round-trip.
Expand All @@ -35,7 +39,7 @@ public void testConfigRoundtrip() throws Exception {
PerforceSCM scm = new PerforceSCM(
"user", "pass", "client", "port", "", "exe", "sysRoot",
"sysDrive", "label", "counter", "upstreamProject", "shared", "charset", "charset2", "user", false, true, true, true, true, true, false,
false, true, false, false, false, "${basename}", 0, -1, browser, "exclude_user", "exclude_file", true, EMPTY_DEPOT, EMPTY_WORKSPACE_CLEANUP, EMPTY_MASKVIEW);
false, true, false, false, false, "${basename}", 0, -1, browser, "exclude_user", "exclude_file", true, TEST_DEPOT, TEST_WORKSPACE_CLEANUP, TEST_MASKVIEW);
scm.setProjectPath("path");
project.setScm(scm);

Expand Down

0 comments on commit ea1acb1

Please sign in to comment.