summaryrefslogtreecommitdiffstats
path: root/java/com/google/gerrit/server/notedb/AbstractChangeNotes.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/com/google/gerrit/server/notedb/AbstractChangeNotes.java')
-rw-r--r--java/com/google/gerrit/server/notedb/AbstractChangeNotes.java16
1 files changed, 9 insertions, 7 deletions
diff --git a/java/com/google/gerrit/server/notedb/AbstractChangeNotes.java b/java/com/google/gerrit/server/notedb/AbstractChangeNotes.java
index a5acbe3ee3..e81160abaa 100644
--- a/java/com/google/gerrit/server/notedb/AbstractChangeNotes.java
+++ b/java/com/google/gerrit/server/notedb/AbstractChangeNotes.java
@@ -118,9 +118,10 @@ public abstract class AbstractChangeNotes<T> {
private ObjectId revision;
private boolean loaded;
- protected AbstractChangeNotes(Args args, Change.Id changeId) {
+ protected AbstractChangeNotes(Args args, Change.Id changeId, @Nullable ObjectId metaSha1) {
this.args = requireNonNull(args);
this.changeId = requireNonNull(changeId);
+ this.revision = metaSha1;
}
public Change.Id getChangeId() {
@@ -152,7 +153,7 @@ public abstract class AbstractChangeNotes<T> {
try (Timer0.Context timer = args.metrics.readLatency.start();
// Call openHandle even if reading is disabled, to trigger
// auto-rebuilding before this object may get passed to a ChangeUpdate.
- LoadHandle handle = openHandle(repo)) {
+ LoadHandle handle = openHandle(repo, revision)) {
revision = handle.id();
onLoad(handle);
loaded = true;
@@ -174,15 +175,16 @@ public abstract class AbstractChangeNotes<T> {
* <p>Implementations may override this method to provide auto-rebuilding behavior.
*
* @param repo open repository.
+ * @param id version SHA1 of the change notes to load
* @return handle for reading the entity.
* @throws NoSuchChangeException change does not exist.
* @throws IOException a repo-level error occurred.
*/
- protected LoadHandle openHandle(Repository repo) throws NoSuchChangeException, IOException {
- return openHandle(repo, readRef(repo));
- }
-
- protected LoadHandle openHandle(Repository repo, ObjectId id) {
+ protected LoadHandle openHandle(Repository repo, @Nullable ObjectId id)
+ throws NoSuchChangeException, IOException {
+ if (id == null) {
+ id = readRef(repo);
+ }
return new LoadHandle(repo, id);
}