Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-16711] Encode the URLs when are shown in the logger #153

Merged
merged 1 commit into from
Dec 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 42 additions & 34 deletions src/main/java/hudson/scm/SubversionChangeLogBuilder.java
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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