Fix rendering of change edits in change and diff screens

During recent refactoring in I2d961f8d and I7ef198dd rendering of
change edits in change and diff screens was broken. Two REST handlers
return 404 now:

* GET /changes/<change-id>/revisions/<revision-id>/files
* GET /changes/<change-id>/revisions/<revision-id>/files/<name>/diff

Rectify it by restoring the removed code.

Test Plan:

* Upload change or create change edit online
* Modify one existing or add new file
* Save changes in editor
* Reload the change
* Open the modified file in diff screen

Change-Id: I8ac1b811d3385ce8c21f563cfa1b30fe81467ea0
This commit is contained in:
David Ostrovsky
2016-01-24 17:18:09 +01:00
committed by Dave Borowitz
parent 39f7907b72
commit dc189e0df0
2 changed files with 10 additions and 5 deletions

View File

@@ -159,7 +159,9 @@ public class PatchScriptFactory implements Callable<PatchScript> {
PatchSet psEntityA = psa != null
? psUtil.get(db, control.getNotes(), psa) : null;
PatchSet psEntityB = psUtil.get(db, control.getNotes(), psb);
PatchSet psEntityB = psb.get() == 0
? new PatchSet(psb)
: psUtil.get(db, control.getNotes(), psb);
aId = psEntityA != null ? toObjectId(psEntityA) : null;
bId = toObjectId(psEntityB);
@@ -218,13 +220,12 @@ public class PatchScriptFactory implements Callable<PatchScript> {
private ObjectId toObjectId(PatchSet ps) throws NoSuchChangeException,
AuthException, NoSuchChangeException, IOException {
if (ps == null || ps.getRevision() == null
|| ps.getRevision().get() == null) {
throw new NoSuchChangeException(changeId);
}
if (ps.getId().get() == 0) {
return getEditRev();
}
if (ps.getRevision() == null || ps.getRevision().get() == null) {
throw new NoSuchChangeException(changeId);
}
try {
return ObjectId.fromString(ps.getRevision().get());