ChangeBundle: Support ChangeMessages from NoteDb

NoteDb doesn't store the original ChangeMessage UUID; instead, it just
populates UUIDs by using the SHA-1 of the commit that added the
message, since a commit can add at most one message. Thus when
comparing bundles from ReviewDb and NoteDb, we need to ignore the
UUID.

Add a new AutoValue type that represents a normalized ChangeMessage
instance, and check that both bundles have the same multiset of
normalized ChangeMessages. We need to use a Multiset as it is valid in
the database to have two ChangeMessages that have all fields exactly
identical except for the UUID. Therefore bundles are only equivalent
if each unique ChangeMessage appears the correct number of times.

The diff output in this case is slightly less helpful than in other
cases, as we don't do a field-by-field diff. An implementation that
tries to match up mostly-identical ChangeMessages for a field-by-field
diff would be much more complicated of an implementation.

Also round tiemstamps when comparing bundles that are not both from
ReviewDb, since at least one of them will have a rounded timestamp
from NoteDb.

Change-Id: Ie180d70fb749a0c27f2ebcbba135e18c72a8fbea
This commit is contained in:
Dave Borowitz
2016-02-25 12:50:04 -05:00
parent b0cfc534c5
commit 019e3ac40f
3 changed files with 212 additions and 32 deletions

View File

@@ -50,7 +50,7 @@ public final class ChangeMessage {
}
@Override
protected void set(String newValue) {
public void set(String newValue) {
uuid = newValue;
}
}
@@ -105,6 +105,10 @@ public final class ChangeMessage {
return writtenOn;
}
public void setWrittenOn(Timestamp ts) {
writtenOn = ts;
}
public String getMessage() {
return message;
}
@@ -120,4 +124,4 @@ public final class ChangeMessage {
public void setPatchSetId(PatchSet.Id id) {
patchset = id;
}
}
}