Fix diff view for files in change edit

If a change edit is viewed in the change screen and the change screen
is not in edit mode, then clicking on any file in the file list
results in a not found screen. This is because the client makes
requests to the server where 'edit' is used as revision and the server
cannot resolve this revision. Other edit-related requests use '0' as
revision for change edits and those succeed.

Fix this by supporting 'edit' as revision for change edits.

Also document '0' and 'edit' as possible values for revision-id.

Change-Id: If93894b330e0c7942a94a532eca84a73a84b06f5
Signed-off-by: Edwin Kempin <ekempin@google.com>
(cherry picked from commit 8cc0babfda)
This commit is contained in:
Edwin Kempin 2016-09-15 15:53:37 +02:00 committed by Paladox none
parent c40eb57da9
commit 8114b6826d
3 changed files with 13 additions and 1 deletions

View File

@ -4156,6 +4156,7 @@ This can be:
* an abbreviated commit ID that uniquely identifies one revision of the
change ("674ac754"), at least 4 digits are required
* a legacy numeric patch number ("1" for first patch set of the change)
* "0" or the literal `edit` for a change edit
[[json-entities]]
== JSON Entities

View File

@ -144,6 +144,17 @@ public class ChangeEditIT extends AbstractDaemonTest {
db.close();
}
@Test
public void parseEditRevision() throws Exception {
assertThat(modifier.createEdit(change, ps)).isEqualTo(RefUpdate.Result.NEW);
// check that '0' is parsed as edit revision
gApi.changes().id(change.getChangeId()).revision(0).comments();
// check that 'edit' is parsed as edit revision
gApi.changes().id(change.getChangeId()).revision("edit").comments();
}
@Test
public void deleteEdit() throws Exception {
assertThat(modifier.createEdit(change, ps)).isEqualTo(RefUpdate.Result.NEW);

View File

@ -104,7 +104,7 @@ public class Revisions implements ChildCollection<ChangeResource, RevisionResour
private List<RevisionResource> find(ChangeResource change, String id)
throws OrmException, IOException, AuthException {
if (id.equals("0")) {
if (id.equals("0") || id.equals("edit")) {
return loadEdit(change, null);
} else if (id.length() < 6 && id.matches("^[1-9][0-9]{0,4}$")) {
// Legacy patch set number syntax.