ChangeInserter: fix comparison of Change.Id to Change.Key

Change key types and method names are confusing, and Java's
Object.equals() was not helping us here. As a result we actually ended
up inserting the same ChangeMessage multiple times, which depending on
the gwtorm backend might or might not have succeeded.

This combined with I5d7fb4cc had the interesting consequence of racing
the row version update with the background mergeability flag update.
If the row version update won, it would have the effect of erasing the
result of the mergeability check, causing spurious "Cannot merge"
warnings.

Change-Id: I8aeb0c87bb2475fa9b49685d27ded48059295547
(cherry picked from commit 6761264d0848163ab48695e2edcb661a74137d9f)
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/ChangeInserter.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/ChangeInserter.java
index ce6bf4c..0da8803 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/change/ChangeInserter.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/ChangeInserter.java
@@ -214,8 +214,12 @@
   }
 
   private boolean messageIsForChange() {
-    return changeMessage != null
-        && changeMessage.getKey().getParentKey().equals(change.getKey());
+    if (changeMessage == null) {
+      return false;
+    }
+    Change.Id id = change.getId();
+    Change.Id msgId = changeMessage.getKey().getParentKey();
+    return msgId.equals(id);
   }
 
   private void insertMessage(ReviewDb db) throws OrmException {