Disallow creating comments on line 0

Users were able to create comments on line 0 by clicking on the
missing side of a hunk and creating a comment there.  This was not
something we expected users to do, resulting in a saved draft which
cannot be displayed as we never draw line 0 of a file.

Bug: GERRIT-262
Change-Id: I3e09bada23be68f417a949b5b6969c8c75523ca5
Signed-off-by: Shawn O. Pearce <sop@google.com>
diff --git a/src/main/java/com/google/gerrit/client/patches/AbstractPatchContentTable.java b/src/main/java/com/google/gerrit/client/patches/AbstractPatchContentTable.java
index 5f5236d..533700c2 100644
--- a/src/main/java/com/google/gerrit/client/patches/AbstractPatchContentTable.java
+++ b/src/main/java/com/google/gerrit/client/patches/AbstractPatchContentTable.java
@@ -254,6 +254,12 @@
 
   private void createCommentEditor(final int suggestRow, final int column,
       final int line, final short file, final String parentUuid) {
+    if (line < 1) {
+      // Refuse to create an editor before the start of the file.
+      //
+      return;
+    }
+
     int row = suggestRow;
     int spans[] = new int[column + 1];
     OUTER: while (row < table.getRowCount()) {
diff --git a/src/main/java/com/google/gerrit/server/rpc/patch/SaveDraft.java b/src/main/java/com/google/gerrit/server/rpc/patch/SaveDraft.java
index 64e2368..86447af 100644
--- a/src/main/java/com/google/gerrit/server/rpc/patch/SaveDraft.java
+++ b/src/main/java/com/google/gerrit/server/rpc/patch/SaveDraft.java
@@ -68,6 +68,11 @@
 
     final Account.Id me = currentUser.getAccountId();
     if (comment.getKey().get() == null) {
+      if (comment.getLine() < 1) {
+        throw new IllegalStateException("Comment line must be >= 1, not "
+            + comment.getLine());
+      }
+
       final PatchLineComment nc =
           new PatchLineComment(new PatchLineComment.Key(patch.getKey(),
               ChangeUtil.messageUUID(db)), comment.getLine(), me, comment