Merge "Don't update the last updated timestamp when running copy-approvals" into stable-3.5
diff --git a/java/com/google/gerrit/server/approval/RecursiveApprovalCopier.java b/java/com/google/gerrit/server/approval/RecursiveApprovalCopier.java
index 87df465..0926daf 100644
--- a/java/com/google/gerrit/server/approval/RecursiveApprovalCopier.java
+++ b/java/com/google/gerrit/server/approval/RecursiveApprovalCopier.java
@@ -101,7 +101,7 @@
@Override
public boolean updateChange(ChangeContext ctx) throws IOException {
Change change = ctx.getChange();
- ChangeUpdate update = ctx.getUpdate(change.currentPatchSetId());
+ ChangeUpdate update = ctx.getUpdate(change.currentPatchSetId(), change.getLastUpdatedOn());
approvalsUtil.persistCopiedApprovals(
ctx.getNotes(),
ctx.getNotes().getCurrentPatchSet(),
diff --git a/java/com/google/gerrit/server/update/BatchUpdate.java b/java/com/google/gerrit/server/update/BatchUpdate.java
index 917e967..232aa98 100644
--- a/java/com/google/gerrit/server/update/BatchUpdate.java
+++ b/java/com/google/gerrit/server/update/BatchUpdate.java
@@ -311,9 +311,14 @@
@Override
public ChangeUpdate getUpdate(PatchSet.Id psId) {
+ return getUpdate(psId, when);
+ }
+
+ @Override
+ public ChangeUpdate getUpdate(PatchSet.Id psId, Timestamp whenOverride) {
ChangeUpdate u = defaultUpdates.get(psId);
if (u == null) {
- u = getNewChangeUpdate(psId);
+ u = getNewChangeUpdate(psId, whenOverride);
defaultUpdates.put(psId, u);
}
return u;
@@ -321,13 +326,18 @@
@Override
public ChangeUpdate getDistinctUpdate(PatchSet.Id psId) {
- ChangeUpdate u = getNewChangeUpdate(psId);
+ return getDistinctUpdate(psId, when);
+ }
+
+ @Override
+ public ChangeUpdate getDistinctUpdate(PatchSet.Id psId, Timestamp whenOverride) {
+ ChangeUpdate u = getNewChangeUpdate(psId, whenOverride);
distinctUpdates.put(psId, u);
return u;
}
- private ChangeUpdate getNewChangeUpdate(PatchSet.Id psId) {
- ChangeUpdate u = changeUpdateFactory.create(notes, user, when);
+ private ChangeUpdate getNewChangeUpdate(PatchSet.Id psId, Timestamp whenOverride) {
+ ChangeUpdate u = changeUpdateFactory.create(notes, user, whenOverride);
if (newChanges.containsKey(notes.getChangeId())) {
u.setAllowWriteToNewRef(true);
}
diff --git a/java/com/google/gerrit/server/update/ChangeContext.java b/java/com/google/gerrit/server/update/ChangeContext.java
index aeabde4..feba541 100644
--- a/java/com/google/gerrit/server/update/ChangeContext.java
+++ b/java/com/google/gerrit/server/update/ChangeContext.java
@@ -20,6 +20,7 @@
import com.google.gerrit.entities.PatchSet;
import com.google.gerrit.server.notedb.ChangeNotes;
import com.google.gerrit.server.notedb.ChangeUpdate;
+import java.sql.Timestamp;
/**
* Context for performing the {@link BatchUpdateOp#updateChange} phase.
@@ -43,6 +44,15 @@
ChangeUpdate getUpdate(PatchSet.Id psId);
/**
+ * Same as {@link ChangeContext#getUpdate}, but allows to override the commit timestamp.
+ *
+ * @param psId patch set ID.
+ * @param whenOverride commit timestamp.
+ * @return handle for change updates.
+ */
+ ChangeUpdate getUpdate(PatchSet.Id psId, Timestamp whenOverride);
+
+ /**
* Gets a new ChangeUpdate for this change at a given patch set.
*
* <p>To get the current patch set ID, use {@link com.google.gerrit.server.PatchSetUtil#current}.
@@ -53,6 +63,15 @@
ChangeUpdate getDistinctUpdate(PatchSet.Id psId);
/**
+ * Same as {@link ChangeContext#getDistinctUpdate}, but allows to override the commit timestamp.
+ *
+ * @param psId patch set ID.
+ * @param whenOverride commit timestamp.
+ * @return handle for change updates.
+ */
+ ChangeUpdate getDistinctUpdate(PatchSet.Id psId, Timestamp whenOverride);
+
+ /**
* Get the up-to-date notes for this change.
*
* <p>The change data is read within the same transaction that {@link