Skip to content

Commit

Permalink
[JENKINS-28343] Add quiet option to p4-plugin sync
Browse files Browse the repository at this point in the history
1) Adding checkboxes and help text for quiet option
2) Adding quiet to Populate constructors
3) Setting quiet option where necessary
  • Loading branch information
rpocase committed May 12, 2015
1 parent 0400e48 commit 5e40be9
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/jenkinsci/plugins/p4/PerforceScm.java
Expand Up @@ -462,7 +462,7 @@ public boolean processWorkspaceBeforeDeletion(Job<?, ?> job,

ClientHelper p4 = new ClientHelper(scmCredential, null, client);
try {
ForceCleanImpl forceClean = new ForceCleanImpl(false, false, null);
ForceCleanImpl forceClean = new ForceCleanImpl(false, false, populate.isQuiet(), null);
logger.info("P4: unsyncing client: " + client);
p4.syncFiles(0, forceClean);
} catch (Exception e) {
Expand Down
Expand Up @@ -130,7 +130,6 @@ public boolean updateFiles() throws Exception {

// Sync revision to re-edit
SyncOptions syncOpts = new SyncOptions();
syncOpts.setNoUpdate(true);
List<IFileSpec> syncMsg = iclient.sync(syncFiles, syncOpts);

for (IFileSpec fileSpec : syncMsg) {
Expand Down Expand Up @@ -207,8 +206,10 @@ private void syncFiles(List<IFileSpec> files, Populate populate)
SyncOptions syncOpts = new SyncOptions();
syncOpts.setServerBypass(!populate.isHave() && !populate.isForce());
syncOpts.setForceUpdate(populate.isForce());
syncOpts.setQuiet(populate.isQuiet());
log("... force update " + populate.isForce());
log("... bypass have " + !populate.isHave());
log("... quiet " + populate.isQuiet());

List<IFileSpec> syncMsg = iclient.sync(files, syncOpts);
validateFileSpecs(syncMsg, "file(s) up-to-date.",
Expand Down Expand Up @@ -369,6 +370,7 @@ private void tidyRevisions(List<IFileSpec> files, Populate populate)

SyncOptions syncOpts = new SyncOptions();
syncOpts.setForceUpdate(true);
syncOpts.setQuiet(populate.isQuiet());
List<IFileSpec> syncMsg = iclient.sync(update, syncOpts);
validateFileSpecs(syncMsg, "file(s) up-to-date.",
"file does not exist");
Expand Down
Expand Up @@ -10,9 +10,9 @@ public class AutoCleanImpl extends Populate {
private final boolean delete;

@DataBoundConstructor
public AutoCleanImpl(boolean replace, boolean delete, boolean modtime,
String pin) {
super(true, false, modtime, pin); // normal sync; no -f, no -p
public AutoCleanImpl(boolean replace, boolean delete, boolean modtime, boolean quiet,
String pin) {
super(true, false, modtime, quiet, pin); // normal sync; no -f, no -p
this.replace = replace;
this.delete = delete;
}
Expand Down
Expand Up @@ -12,8 +12,8 @@ public class ForceCleanImpl extends Populate {
* @param have
*/
@DataBoundConstructor
public ForceCleanImpl(boolean have, boolean modtime, String pin) {
super(have, true, modtime, pin);
public ForceCleanImpl(boolean have, boolean modtime, boolean quiet, String pin) {
super(have, true, modtime, quiet, pin);
}

@Extension
Expand Down
Expand Up @@ -16,13 +16,15 @@ public abstract class Populate implements ExtensionPoint,
private final boolean have; // ! sync '-p'
private final boolean force; // sync '-f'
private final boolean modtime;
private final boolean quiet; // task '-q'
private final String pin;

public Populate(boolean have, boolean force, boolean modtime, String pin) {
public Populate(boolean have, boolean force, boolean modtime, boolean quiet, String pin) {
this.have = have;
this.force = force;
this.modtime = modtime;
this.pin = pin;
this.quiet = quiet;
}

public boolean isHave() {
Expand All @@ -37,6 +39,8 @@ public boolean isModtime() {
return modtime;
}

public boolean isQuiet() { return quiet; }

public String getPin() {
return pin;
}
Expand Down
Expand Up @@ -12,8 +12,8 @@ public class SyncOnlyImpl extends Populate {
* @param have
*/
@DataBoundConstructor
public SyncOnlyImpl(boolean have, boolean modtime, String pin) {
super(have, false, modtime, pin);
public SyncOnlyImpl(boolean have, boolean modtime, boolean quiet, String pin) {
super(have, false, modtime, quiet, pin);
}

@Extension
Expand Down
Expand Up @@ -11,6 +11,10 @@
<f:entry field="modtime">
<f:checkbox title="${%Sync with MODTIME for consistency check}" default="false"/>
</f:entry>

<f:entry field="quiet">
<f:checkbox title="${%Suppress Perforce generated info messages}" default="false"/>
</f:entry>

<f:entry field="pin">
<table border="0" width="100%">
Expand Down
@@ -0,0 +1,4 @@
<div>
<b>Suppressing info messages</b>
<p>Enables the -q flag for all applicable Perforce operations. Summary details will still be displayed.</p>
</div>
Expand Up @@ -7,6 +7,10 @@
<f:entry field="modtime">
<f:checkbox title="${%Sync with MODTIME for consistency check}" default="false"/>
</f:entry>

<f:entry field="quiet">
<f:checkbox title="${%Suppress Perforce generated info messages}" default="false"/>
</f:entry>

<f:entry field="pin">
<table border="0" width="100%">
Expand Down
@@ -0,0 +1,4 @@
<div>
<b>Suppressing info messages</b>
<p>Enables the -q flag for all applicable Perforce operations. Summary details will still be displayed.</p>
</div>
Expand Up @@ -7,6 +7,10 @@
<f:entry field="modtime">
<f:checkbox title="${%Sync with MODTIME for consistency check}" default="false"/>
</f:entry>

<f:entry field="quiet">
<f:checkbox title="${%Suppress Perforce generated info messages}" default="false"/>
</f:entry>

<f:entry field="pin">
<table border="0" width="100%">
Expand Down
@@ -0,0 +1,4 @@
<div>
<b>Suppressing info messages</b>
<p>Enables the -q flag for all applicable Perforce operations. Summary details will still be displayed.</p>
</div>
Expand Up @@ -24,7 +24,7 @@ public void testConfigBasic() throws Exception {

String credential = "123";
Workspace workspace = new StaticWorkspaceImpl("none", false, "test.ws");
Populate populate = new AutoCleanImpl(true, true, false, null);
Populate populate = new AutoCleanImpl(true, true, false, false, null);
PerforceScm scm = new PerforceScm(credential, workspace, populate);

project.setScm(scm);
Expand Down
28 changes: 14 additions & 14 deletions src/test/java/org/jenkinsci/plugins/p4/client/ConnectionTest.java
Expand Up @@ -138,7 +138,7 @@ public void testCredentialsList() throws Exception {
FreeStyleProject project = jenkins
.createFreeStyleProject("Static-Head");
Workspace workspace = new StaticWorkspaceImpl("none", false, "test.ws");
Populate populate = new AutoCleanImpl(true, true, false, null);
Populate populate = new AutoCleanImpl(true, true, false, false, null);
PerforceScm scm = new PerforceScm(credential, workspace, populate);
project.setScm(scm);
project.save();
Expand All @@ -165,7 +165,7 @@ public void testFreeStyleProject_buildHead() throws Exception {
FreeStyleProject project = jenkins
.createFreeStyleProject("Static-Head");
Workspace workspace = new StaticWorkspaceImpl("none", false, "test.ws");
Populate populate = new AutoCleanImpl(true, true, false, null);
Populate populate = new AutoCleanImpl(true, true, false, false, null);
PerforceScm scm = new PerforceScm(credential, workspace, populate);
project.setScm(scm);
project.save();
Expand Down Expand Up @@ -206,7 +206,7 @@ public void testPinHost_ManualWs() throws Exception {
.createFreeStyleProject("Manual-Head");
ManualWorkspaceImpl workspace = new ManualWorkspaceImpl("none", true,
client, spec);
Populate populate = new AutoCleanImpl(true, true, false, null);
Populate populate = new AutoCleanImpl(true, true, false, false, null);
PerforceScm scm = new PerforceScm(credential, workspace, populate);
project.setScm(scm);
project.save();
Expand Down Expand Up @@ -238,7 +238,7 @@ public void testFreeStyleProject_buildChange() throws Exception {
.createFreeStyleProject("Static-Change");
StaticWorkspaceImpl workspace = new StaticWorkspaceImpl("none", false,
"test.ws");
Populate populate = new AutoCleanImpl(true, true, false, null);
Populate populate = new AutoCleanImpl(true, true, false, false, null);
PerforceScm scm = new PerforceScm(credential, workspace, populate);
project.setScm(scm);
project.save();
Expand Down Expand Up @@ -300,7 +300,7 @@ public void testFreeStyleProject_buildLabel() throws Exception {
.createFreeStyleProject("Static-Change");
StaticWorkspaceImpl workspace = new StaticWorkspaceImpl("none", false,
"test.ws");
Populate populate = new AutoCleanImpl(true, true, false, null);
Populate populate = new AutoCleanImpl(true, true, false, false, null);
PerforceScm scm = new PerforceScm(credential, workspace, null,
populate, browser);
project.setScm(scm);
Expand Down Expand Up @@ -362,7 +362,7 @@ public void testFreeStyleProject_buildShelf() throws Exception {
FreeStyleProject project = jenkins
.createFreeStyleProject("Static-Shelf");
Workspace workspace = new StaticWorkspaceImpl("none", false, "test.ws");
Populate populate = new AutoCleanImpl(true, true, false, null);
Populate populate = new AutoCleanImpl(true, true, false, false, null);
PerforceScm scm = new PerforceScm(credential, workspace, null,
populate, browser);
project.setScm(scm);
Expand Down Expand Up @@ -421,7 +421,7 @@ public void testFreeStyleProject_ManualWs() throws Exception {
.createFreeStyleProject("Manual-Head");
ManualWorkspaceImpl workspace = new ManualWorkspaceImpl("none", false,
client, spec);
Populate populate = new AutoCleanImpl(true, true, false, null);
Populate populate = new AutoCleanImpl(true, true, false, false, null);
PerforceScm scm = new PerforceScm(credential, workspace, populate);
project.setScm(scm);
project.save();
Expand Down Expand Up @@ -480,7 +480,7 @@ public void testFreeStyleProject_TemplateWs() throws Exception {
.createFreeStyleProject("Template-Head");
TemplateWorkspaceImpl workspace = new TemplateWorkspaceImpl("none",
false, client, format);
Populate populate = new AutoCleanImpl(true, true, false, null);
Populate populate = new AutoCleanImpl(true, true, false, false, null);
PerforceScm scm = new PerforceScm(credential, workspace, populate);
project.setScm(scm);
project.save();
Expand Down Expand Up @@ -525,7 +525,7 @@ public void testFreeStyleProject_StreamWs() throws Exception {
.createFreeStyleProject("Stream-Head");
StreamWorkspaceImpl workspace = new StreamWorkspaceImpl("none", false,
stream, format);
Populate populate = new AutoCleanImpl(true, true, false, null);
Populate populate = new AutoCleanImpl(true, true, false, false, null);
PerforceScm scm = new PerforceScm(credential, workspace, populate);
project.setScm(scm);
project.save();
Expand Down Expand Up @@ -564,7 +564,7 @@ public void testTPI83() throws Exception {

FreeStyleProject project = jenkins.createFreeStyleProject("TPI83");
Workspace workspace = new StaticWorkspaceImpl("none", false, "test.ws");
Populate populate = new AutoCleanImpl(true, true, false, null);
Populate populate = new AutoCleanImpl(true, true, false, false, null);
PerforceScm scm = new PerforceScm(credential, workspace, populate);
project.setScm(scm);
project.save();
Expand Down Expand Up @@ -598,7 +598,7 @@ public void testTPI95() throws Exception {
.createFreeStyleProject("Template-Head");
TemplateWorkspaceImpl workspace = new TemplateWorkspaceImpl("none",
false, client, format);
Populate populate = new AutoCleanImpl(true, true, false, null);
Populate populate = new AutoCleanImpl(true, true, false, false, null);
PerforceScm scm = new PerforceScm(credential, workspace, populate);
project.setScm(scm);
project.save();
Expand Down Expand Up @@ -643,7 +643,7 @@ public void testPolling_Pin() throws Exception {
client, spec);

// Pin at label auto15
Populate populate = new AutoCleanImpl(true, true, false, "auto15");
Populate populate = new AutoCleanImpl(true, true, false, false, "auto15");
PerforceScm scm = new PerforceScm(credential, workspace, populate);
project.setScm(scm);
project.save();
Expand Down Expand Up @@ -688,7 +688,7 @@ public void testPolling_Inc() throws Exception {
client, spec);

// Pin at label auto15
Populate populate = new AutoCleanImpl(true, true, false, "auto15");
Populate populate = new AutoCleanImpl(true, true, false, false, "auto15");
List<Filter> filter = new ArrayList<Filter>();
FilterPerChangeImpl inc = new FilterPerChangeImpl(true);
filter.add(inc);
Expand Down Expand Up @@ -737,7 +737,7 @@ public void testManual_Modtime() throws Exception {
ManualWorkspaceImpl workspace = new ManualWorkspaceImpl("none", false,
client, spec);
boolean isModtime = true;
Populate populate = new AutoCleanImpl(true, true, isModtime, null);
Populate populate = new AutoCleanImpl(true, true, isModtime, false, null);
PerforceScm scm = new PerforceScm(credential, workspace, populate);
project.setScm(scm);
project.save();
Expand Down
Expand Up @@ -38,7 +38,7 @@ public void testStaticReviewImpl() throws Exception {
FreeStyleProject project = jenkins
.createFreeStyleProject("StaticReview");
Workspace workspace = new StaticWorkspaceImpl("none", false, client);
Populate populate = new AutoCleanImpl(true, true, false, null);
Populate populate = new AutoCleanImpl(true, true, false, false, null);
PerforceScm scm = new PerforceScm(credential, workspace, populate);
project.setScm(scm);
project.save();
Expand Down

0 comments on commit 5e40be9

Please sign in to comment.