Populate createdOn and lastUpdatedOn fields of a change from notedb

createdOn/lastUpdatedOn is set to the timestamp of the first/last
commit on the notes branch.

The initial update of the change notes must create a commit even when
it is empty so that the createdOn timestamp is recorded. This initial
update is done when the change is created.

To reflect this is in AbstractChangeNotesTest the newChange method
which creates a change is updated to also make an initial update to
the change notes. As consequence of this all tests that assert
timestamps must be adapted because the creation of the initial update
of the change notes consumes one timestamp.

Also the newUpdate method in AbstractChangeNotesTest is adapted to
load the ChangeUpdate that it creates so that its revision field gets
populated. Due to this tests that expected that the revision was null
had to be changed as well.

The multipleUpdatesIncludingComments test started to fail because the
same RevWalk instance was passed two times into ChangeNotesParser.
ChangeNotesParser walks the commits and for the second
ChangeNotesParser instance the walk was already done. Instead of
resetting the RevWalk, create a new one since this is easier to read.

PostReview must take care to set the new lastUpdatedOn timestamp on
the change only after the lastUpdatedOn field was populated from
notedb, otherwise the lastUpdatedOn timestamp in the database will not
be updated.

Change-Id: I24e385e32052fc3286fab50c7377686f425baf1f
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2016-01-13 15:59:05 -08:00
committed by Dave Borowitz
parent ed44d909ea
commit 9c6c080ca7
8 changed files with 99 additions and 26 deletions

View File

@@ -523,6 +523,10 @@ public final class Change {
return createdOn;
}
public void setCreatedOn(Timestamp ts) {
createdOn = ts;
}
public Timestamp getLastUpdatedOn() {
return lastUpdatedOn;
}