Skip to content

Commit

Permalink
[JENKINS-7747] encode the changelist number directly in the changelog…
Browse files Browse the repository at this point in the history
….xml for every file so the SCM browsers can retreive it
  • Loading branch information
rpetti committed Jun 29, 2011
1 parent 3bfb2e2 commit a8d7a02
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
9 changes: 5 additions & 4 deletions src/main/java/com/tek42/perforce/model/Changelist.java
Expand Up @@ -104,6 +104,7 @@ public static enum Action {
Action action;
String filename;
String revision;
String changenumber;
String workspacePath;
Changelist changelist;

Expand Down Expand Up @@ -180,12 +181,12 @@ public void setWorkspacePath(String workspacePath) {
this.workspacePath = workspacePath;
}

public void setChangelist(Changelist changelist) {
this.changelist = changelist;
public void setChangenumber(String changenumber) {
this.changenumber = changenumber;
}

public Changelist getChangelist() {
return this.changelist;
public String getChangenumber() {
return this.changenumber;
}

public String getPath() {
Expand Down
Expand Up @@ -171,7 +171,7 @@ public Changelist build(StringBuilder sb) throws PerforceException {
Changelist.FileEntry file = new Changelist.FileEntry();
file.setFilename(filename);
file.setRevision(rev);
file.setChangelist(change);
file.setChangenumber(Integer.valueOf(change.getChangeNumber()).toString());
file.setAction(Changelist.FileEntry.Action.valueOf(action.toUpperCase(Locale.US)));
files.add(file);
}
Expand Down
Expand Up @@ -115,6 +115,11 @@ public static PerforceChangeLogSet parse(AbstractBuild build, InputStream change
//This field might not exist yet, so ignore it.
}
file.setRevision(fnode.selectSingleNode("rev").getStringValue());
try{
file.setChangenumber(fnode.selectSingleNode("changenumber").getStringValue());
}catch(Exception e){
//This field might not exist yet, so ignore it.
}
file.setAction(Changelist.FileEntry.Action.valueOf(fnode.selectSingleNode("action")
.getStringValue()));
files.add(file);
Expand Down Expand Up @@ -172,6 +177,7 @@ public static void saveToChangeLog(OutputStream outputStream, List<Changelist> c
stream.println("\t\t\t\t<name>" + Util.xmlEscape(entry.getFilename()) + "</name>");
stream.println("\t\t\t\t<workspacePath>" + Util.xmlEscape(entry.getWorkspacePath()) + "</workspacePath>");
stream.println("\t\t\t\t<rev>" + Util.xmlEscape(entry.getRevision()) + "</rev>");
stream.println("\t\t\t\t<changenumber>" + Util.xmlEscape(entry.getChangenumber()) + "</changenumber>");
stream.println("\t\t\t\t<action>" + entry.getAction() + "</action>");
stream.println("\t\t\t</file>");
}
Expand Down
Expand Up @@ -44,10 +44,10 @@ public FishEyePerforce(URL url, String rootModule) {
public URL getDiffLink(Changelist.FileEntry file) throws IOException {
if(file.getAction() != Changelist.FileEntry.Action.EDIT && file.getAction() != Changelist.FileEntry.Action.INTEGRATE)
return null;
Changelist change = file.getChangelist();
String change = file.getChangenumber();
int r=0;
if(change != null){
r = new Integer(change.getChangeNumber());
r = new Integer(change);
} else {
//this is the old, incorrect behavior. New changes won't use this.
r = new Integer(file.getRevision());
Expand Down

0 comments on commit a8d7a02

Please sign in to comment.