Skip to content

Commit

Permalink
Merge "Don't update the last updated timestamp when running copy-appr…
Browse files Browse the repository at this point in the history
…ovals" into stable-3.5
  • Loading branch information
thomasdraebing authored and Gerrit Code Review committed Oct 6, 2022
2 parents a527652 + 124d682 commit d6b2853
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private static class PersistCopiedVotesOp implements BatchUpdateOp {
@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(),
Expand Down
18 changes: 14 additions & 4 deletions java/com/google/gerrit/server/update/BatchUpdate.java
Original file line number Diff line number Diff line change
Expand Up @@ -311,23 +311,33 @@ private class ChangeContextImpl extends ContextImpl implements ChangeContext {

@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;
}

@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);
}
Expand Down
19 changes: 19 additions & 0 deletions java/com/google/gerrit/server/update/ChangeContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -42,6 +43,15 @@ public interface ChangeContext extends Context {
*/
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.
*
Expand All @@ -52,6 +62,15 @@ public interface ChangeContext extends Context {
*/
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.
*
Expand Down

0 comments on commit d6b2853

Please sign in to comment.