Remove unnecessary reference of patch key in save draft
Instead of looking for the patch, look for the patch set. There may be some value in allowing users to comment on files which are *not* modified by the patch set, and make those comments visible to any other viewer of the change. Currently the UI does not support this, and may not for some time, but its a reasonable thing to want to do in order to facilitate a review process, and this avoids needing to deal with the Patch entity, which I want to remove from the database. Change-Id: Ib4eeda25cea8ff25d36f37697a4fd4525f2f6777 Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
		| @@ -18,6 +18,7 @@ import com.google.gerrit.client.reviewdb.Account; | ||||
| import com.google.gerrit.client.reviewdb.Change; | ||||
| import com.google.gerrit.client.reviewdb.Patch; | ||||
| import com.google.gerrit.client.reviewdb.PatchLineComment; | ||||
| import com.google.gerrit.client.reviewdb.PatchSet; | ||||
| import com.google.gerrit.client.reviewdb.ReviewDb; | ||||
| import com.google.gerrit.server.ChangeUtil; | ||||
| import com.google.gerrit.server.IdentifiedUser; | ||||
| @@ -59,10 +60,10 @@ class SaveDraft extends Handler<PatchLineComment> { | ||||
|     } | ||||
|  | ||||
|     final Patch.Key patchKey = comment.getKey().getParentKey(); | ||||
|     final PatchSet.Id patchSetId = patchKey.getParentKey(); | ||||
|     final Change.Id changeId = patchKey.getParentKey().getParentKey(); | ||||
|     changeControlFactory.validateFor(changeId); | ||||
|     final Patch patch = db.patches().get(patchKey); | ||||
|     if (patch == null) { | ||||
|     if (db.patchSets().get(patchSetId) == null) { | ||||
|       throw new NoSuchChangeException(changeId); | ||||
|     } | ||||
|  | ||||
| @@ -74,9 +75,8 @@ class SaveDraft extends Handler<PatchLineComment> { | ||||
|       } | ||||
|  | ||||
|       final PatchLineComment nc = | ||||
|           new PatchLineComment(new PatchLineComment.Key(patch.getKey(), | ||||
|               ChangeUtil.messageUUID(db)), comment.getLine(), me, comment | ||||
|               .getParentUuid()); | ||||
|           new PatchLineComment(new PatchLineComment.Key(patchKey, ChangeUtil | ||||
|               .messageUUID(db)), comment.getLine(), me, comment.getParentUuid()); | ||||
|       nc.setSide(comment.getSide()); | ||||
|       nc.setMessage(comment.getMessage()); | ||||
|       db.patchComments().insert(Collections.singleton(nc)); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Shawn O. Pearce
					Shawn O. Pearce