Skip to content

Commit

Permalink
Merge pull request #153 from recena/JENKINS-16711-PART3
Browse files Browse the repository at this point in the history
[JENKINS-16711] Encode the URLs when are shown in the logger
  • Loading branch information
recena committed Dec 30, 2015
2 parents 94b8c22 + ec10c72 commit 9101392
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 39 deletions.
76 changes: 42 additions & 34 deletions src/main/java/hudson/scm/SubversionChangeLogBuilder.java
Expand Up @@ -155,48 +155,56 @@ private boolean buildModule(PathContext context, SVNLogClient svnlc, DirAwareSVN
String url = context.url;
PrintStream logger = listener.getLogger();

Long prevRev = previousRevisions.get(url);
if (prevRev == null) {
logger.println("No revision recorded for " + url + " in the previous build");
return false;
}
try {
SVNURL repoURL = SVNURL.parseURIEncoded(url);

Long thisRev = thisRevisions.get(url);
if (thisRev == null) {
listener.error("No revision found for " + url + " in " + SubversionSCM.getRevisionFile(build) + ". Revision file contains: " + thisRevisions.keySet());
return false;
}
Long prevRev = previousRevisions.get(url);
if (prevRev == null) {
logger.println("No revision recorded for " + repoURL + " in the previous build");
return false;
}

if (thisRev.equals(prevRev)) {
logger.println("No changes for " + url + " since the previous build");
return false;
}
Long thisRev = thisRevisions.get(url);
if (thisRev == null) {
listener.error("No revision found for " + repoURL + " in " + SubversionSCM.getRevisionFile(build) + "" +
". Revision file contains: " + thisRevisions.keySet());
return false;
}

// handle case where previous workspace revision is newer than this revision
if (prevRev.compareTo(thisRev) > 0) {
long temp = thisRev;
thisRev = prevRev;
prevRev = temp;
}
if (thisRev.equals(prevRev)) {
logger.println("No changes for " + repoURL + " since the previous build");
return false;
}

logHandler.setContext(context);
try {
if(debug)
// handle case where previous workspace revision is newer than this revision
if (prevRev.compareTo(thisRev) > 0) {
long temp = thisRev;
thisRev = prevRev;
prevRev = temp;
}

logHandler.setContext(context);

if (debug) {
listener.getLogger().printf("Computing changelog of %1s from %2s to %3s%n",
SVNURL.parseURIEncoded(url), prevRev+1, thisRev);
SVNURL.parseURIEncoded(url), prevRev + 1, thisRev);
}

svnlc.doLog(SVNURL.parseURIEncoded(url),
null,
SVNRevision.UNDEFINED,
SVNRevision.create(prevRev+1),
SVNRevision.create(thisRev),
false, // Don't stop on copy.
true, // Report paths.
0, // Retrieve log entries for unlimited number of revisions.
debug ? new DebugSVNLogHandler(logHandler) : logHandler);
if(debug)
null,
SVNRevision.UNDEFINED,
SVNRevision.create(prevRev + 1),
SVNRevision.create(thisRev),
false, // Don't stop on copy.
true, // Report paths.
0, // Retrieve log entries for unlimited number of revisions.
debug ? new DebugSVNLogHandler(logHandler) : logHandler);

if (debug) {
listener.getLogger().println("done");
}
} catch (SVNException e) {
throw new IOException2("revision check failed on "+url,e);
throw new IOException2("revision check failed on " + url, e);
}
return true;
}
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/hudson/scm/SubversionEventHandlerImpl.java
Expand Up @@ -57,19 +57,19 @@ public void handleEvent(SVNEvent event, double progress) throws SVNException {

{// commit notifications
if (action == SVNEventAction.COMMIT_ADDED) {
out.println("Adding "+path);
out.println("Adding " + path);
return;
}
if (action == SVNEventAction.COMMIT_DELETED) {
out.println("Deleting "+path);
out.println("Deleting " + path);
return;
}
if (action == SVNEventAction.COMMIT_MODIFIED) {
out.println("Sending "+path);
out.println("Sending " + path);
return;
}
if (action == SVNEventAction.COMMIT_REPLACED) {
out.println("Replacing "+path);
out.println("Replacing " + path);
return;
}
if (action == SVNEventAction.COMMIT_DELTA_SENT) {
Expand Down Expand Up @@ -100,7 +100,7 @@ public void handleEvent(SVNEvent event, double progress) throws SVNException {
* from the repository
*/
pathChangeType = "U";
}else if (contentsStatus == SVNStatusType.CONFLICTED) {
} else if (contentsStatus == SVNStatusType.CONFLICTED) {
/*
* The file item is in a state of Conflict. That is, changes
* received from the repository during an update, overlap with
Expand All @@ -118,6 +118,7 @@ public void handleEvent(SVNEvent event, double progress) throws SVNException {
} else if (action == SVNEventAction.UPDATE_COMPLETED) {
// finished updating
out.println("At revision " + event.getRevision());
out.println();
return;
} else if (action == SVNEventAction.ADD){
out.println("A " + path);
Expand Down

0 comments on commit 9101392

Please sign in to comment.