Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FIXED JENKINS-14216] fixing NPE and some other inconsistencies when …
…polling using view from a file
  • Loading branch information
rpetti committed Jun 27, 2012
1 parent c014778 commit 079f647
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/tek42/perforce/parse/File.java
Expand Up @@ -20,7 +20,7 @@ public boolean exists() throws PerforceException {
}

public String read() throws PerforceException {
StringBuilder sb = getPerforceResponse(new String[] { getP4Exe(), "print", file });
StringBuilder sb = getPerforceResponse(new String[] { getP4Exe(), "print", "-q", file });
return sb.toString();
}
}
24 changes: 15 additions & 9 deletions src/main/java/hudson/plugins/perforce/PerforceSCM.java
Expand Up @@ -587,6 +587,16 @@ private Hashtable<String, String> getDefaultSubstitutions(AbstractProject projec
return subst;
}

private String getEffectiveProjectPath(AbstractBuild build, AbstractProject project, PrintStream log, Depot depot) throws PerforceException {
String projectPath;
if (useClientSpec) {
projectPath = getEffectiveProjectPathFromFile(build, project, log, depot);
} else {
projectPath = substituteParameters(this.projectPath, build);
}
return projectPath;
}

private String getEffectiveProjectPathFromFile(AbstractBuild build, AbstractProject project, PrintStream log, Depot depot) throws PerforceException {
String clientSpec;
if (build != null) {
Expand Down Expand Up @@ -772,11 +782,7 @@ public boolean checkout(AbstractBuild build, Launcher launcher,
try {
// keep projectPath local so any modifications for slaves don't get saved
String projectPath;
if (useClientSpec) {
projectPath = getEffectiveProjectPathFromFile(build, build.getProject(), log, depot);
} else {
projectPath = substituteParameters(this.projectPath, build);
}
projectPath = getEffectiveProjectPath(build, build.getProject(), log, depot);

Workspace p4workspace = getPerforceWorkspace(build.getProject(), projectPath, depot, build.getBuiltOn(), build, launcher, workspace, listener, false);

Expand Down Expand Up @@ -1136,7 +1142,7 @@ protected PollingResult compareRemoteRevisionWith(AbstractProject<?, ?> project,
logger.println("Using node: " + buildNode.getDisplayName());
}

Workspace p4workspace = getPerforceWorkspace(project, substituteParameters(projectPath, subst), depot, buildNode, null, launcher, workspace, listener, true);
Workspace p4workspace = getPerforceWorkspace(project, getEffectiveProjectPath(null, project, logger, depot), depot, buildNode, null, launcher, workspace, listener, true);
saveWorkspaceIfDirty(depot, p4workspace, logger);

int lastChangeNumber = baseline.getRevision();
Expand Down Expand Up @@ -1260,7 +1266,7 @@ private SCMRevisionState getCurrentDepotRevisionState(Workspace p4workspace, Abs
}
else {
for (int changeNumber : changeNumbers) {
if (isChangelistExcluded(depot.getChanges().getChangelist(changeNumber, fileLimit), project, logger)) {
if (isChangelistExcluded(depot.getChanges().getChangelist(changeNumber, fileLimit), project, p4workspace.getViewsAsString(), logger)) {
logger.println("Changelist "+changeNumber+" is composed of file(s) and/or user(s) that are excluded.");
} else {
return new PerforceSCMRevisionState(changeNumber);
Expand All @@ -1277,7 +1283,7 @@ private SCMRevisionState getCurrentDepotRevisionState(Workspace p4workspace, Abs
* @param changelist the p4 changelist
* @return True if changelist only contains user(s) and/or file(s) that are denoted to be excluded
*/
private boolean isChangelistExcluded(Changelist changelist, AbstractProject project, PrintStream logger) {
private boolean isChangelistExcluded(Changelist changelist, AbstractProject project, String view, PrintStream logger) {
if (changelist == null) {
return false;
}
Expand Down Expand Up @@ -1311,7 +1317,7 @@ private boolean isChangelistExcluded(Changelist changelist, AbstractProject proj
if (files.size() > 0 && changelist.getFiles().size() > 0) {
for (FileEntry f : changelist.getFiles()) {
if (!doesFilenameMatchAnyP4Pattern(f.getFilename(),files,excludedFilesCaseSensitivity) &&
isFileInView(f.getFilename(), substituteParameters(projectPath, getDefaultSubstitutions(project)),excludedFilesCaseSensitivity)) {
isFileInView(f.getFilename(), view, excludedFilesCaseSensitivity)) {
return false;
}

Expand Down

0 comments on commit 079f647

Please sign in to comment.