Merge changes Ibe956014,I4222b894,Iac4ea144,I803717e8,I39e97dcd, ...
* changes: Support updating multiple VersionedMetaDatas in a BatchRefUpdate Refactor byChange() into two methods: drafts and published Add draft comments to PatchLineCommentsUtil Fix bug for comments with no range Resolve issue with naming of drafts ref Add method to parse an AccountId out of a RefName Improve PatchSet.Id.fromRef performance and avoid double-parsing
This commit is contained in:
@@ -30,7 +30,8 @@ public class BasicChangeRewrites extends QueryRewriter<ChangeData> {
|
||||
new InvalidProvider<ReviewDb>(), //
|
||||
new InvalidProvider<ChangeQueryRewriter>(), //
|
||||
null, null, null, null, null, null, null, //
|
||||
null, null, null, null, null, null, null, null, null, null), null);
|
||||
null, null, null, null, null, null, null, null, null, null, null),
|
||||
null);
|
||||
|
||||
private static final QueryRewriter.Definition<ChangeData, BasicChangeRewrites> mydef =
|
||||
new QueryRewriter.Definition<ChangeData, BasicChangeRewrites>(
|
||||
|
||||
@@ -35,6 +35,7 @@ import com.google.gerrit.server.ApprovalsUtil;
|
||||
import com.google.gerrit.server.ChangeMessagesUtil;
|
||||
import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.PatchLineCommentsUtil;
|
||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
import com.google.gerrit.server.notedb.ChangeNotes;
|
||||
import com.google.gerrit.server.notedb.NotesMigration;
|
||||
@@ -154,7 +155,7 @@ public class ChangeData {
|
||||
*/
|
||||
static ChangeData createForTest(Change.Id id, int currentPatchSetId) {
|
||||
ChangeData cd = new ChangeData(null, null, null, null, null,
|
||||
null, null, null, null, id);
|
||||
null, null, null, null, null, id);
|
||||
cd.currentPatchSet = new PatchSet(new PatchSet.Id(id, currentPatchSetId));
|
||||
return cd;
|
||||
}
|
||||
@@ -166,6 +167,7 @@ public class ChangeData {
|
||||
private final ChangeNotes.Factory notesFactory;
|
||||
private final ApprovalsUtil approvalsUtil;
|
||||
private final ChangeMessagesUtil cmUtil;
|
||||
private final PatchLineCommentsUtil plcUtil;
|
||||
private final PatchListCache patchListCache;
|
||||
private final NotesMigration notesMigration;
|
||||
private final Change.Id legacyId;
|
||||
@@ -179,7 +181,7 @@ public class ChangeData {
|
||||
private ListMultimap<PatchSet.Id, PatchSetApproval> allApprovals;
|
||||
private List<PatchSetApproval> currentApprovals;
|
||||
private Map<Integer, List<String>> files = new HashMap<>();
|
||||
private Collection<PatchLineComment> comments;
|
||||
private Collection<PatchLineComment> publishedComments;
|
||||
private CurrentUser visibleTo;
|
||||
private ChangeControl changeControl;
|
||||
private List<ChangeMessage> messages;
|
||||
@@ -194,6 +196,7 @@ public class ChangeData {
|
||||
ChangeNotes.Factory notesFactory,
|
||||
ApprovalsUtil approvalsUtil,
|
||||
ChangeMessagesUtil cmUtil,
|
||||
PatchLineCommentsUtil plcUtil,
|
||||
PatchListCache patchListCache,
|
||||
NotesMigration notesMigration,
|
||||
@Assisted ReviewDb db,
|
||||
@@ -205,6 +208,7 @@ public class ChangeData {
|
||||
this.notesFactory = notesFactory;
|
||||
this.approvalsUtil = approvalsUtil;
|
||||
this.cmUtil = cmUtil;
|
||||
this.plcUtil = plcUtil;
|
||||
this.patchListCache = patchListCache;
|
||||
this.notesMigration = notesMigration;
|
||||
legacyId = id;
|
||||
@@ -218,6 +222,7 @@ public class ChangeData {
|
||||
ChangeNotes.Factory notesFactory,
|
||||
ApprovalsUtil approvalsUtil,
|
||||
ChangeMessagesUtil cmUtil,
|
||||
PatchLineCommentsUtil plcUtil,
|
||||
PatchListCache patchListCache,
|
||||
NotesMigration notesMigration,
|
||||
@Assisted ReviewDb db,
|
||||
@@ -229,6 +234,7 @@ public class ChangeData {
|
||||
this.notesFactory = notesFactory;
|
||||
this.approvalsUtil = approvalsUtil;
|
||||
this.cmUtil = cmUtil;
|
||||
this.plcUtil = plcUtil;
|
||||
this.patchListCache = patchListCache;
|
||||
this.notesMigration = notesMigration;
|
||||
legacyId = c.getId();
|
||||
@@ -243,6 +249,7 @@ public class ChangeData {
|
||||
ChangeNotes.Factory notesFactory,
|
||||
ApprovalsUtil approvalsUtil,
|
||||
ChangeMessagesUtil cmUtil,
|
||||
PatchLineCommentsUtil plcUtil,
|
||||
PatchListCache patchListCache,
|
||||
NotesMigration notesMigration,
|
||||
@Assisted ReviewDb db,
|
||||
@@ -254,6 +261,7 @@ public class ChangeData {
|
||||
this.notesFactory = notesFactory;
|
||||
this.approvalsUtil = approvalsUtil;
|
||||
this.cmUtil = cmUtil;
|
||||
this.plcUtil = plcUtil;
|
||||
this.patchListCache = patchListCache;
|
||||
this.notesMigration = notesMigration;
|
||||
legacyId = c.getChange().getId();
|
||||
@@ -519,12 +527,12 @@ public class ChangeData {
|
||||
return approvalsUtil.getReviewers(notes(), approvals().values());
|
||||
}
|
||||
|
||||
public Collection<PatchLineComment> comments()
|
||||
public Collection<PatchLineComment> publishedComments()
|
||||
throws OrmException {
|
||||
if (comments == null) {
|
||||
comments = db.patchComments().byChange(legacyId).toList();
|
||||
if (publishedComments == null) {
|
||||
publishedComments = plcUtil.publishedByChange(db, notes());
|
||||
}
|
||||
return comments;
|
||||
return publishedComments;
|
||||
}
|
||||
|
||||
public List<ChangeMessage> messages()
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.PatchLineCommentsUtil;
|
||||
import com.google.gerrit.server.account.AccountResolver;
|
||||
import com.google.gerrit.server.account.CapabilityControl;
|
||||
import com.google.gerrit.server.account.GroupBackend;
|
||||
@@ -146,6 +147,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
||||
final CapabilityControl.Factory capabilityControlFactory;
|
||||
final ChangeControl.GenericFactory changeControlGenericFactory;
|
||||
final ChangeData.Factory changeDataFactory;
|
||||
final PatchLineCommentsUtil plcUtil;
|
||||
final AccountResolver accountResolver;
|
||||
final GroupBackend groupBackend;
|
||||
final AllProjectsName allProjectsName;
|
||||
@@ -168,6 +170,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
||||
CapabilityControl.Factory capabilityControlFactory,
|
||||
ChangeControl.GenericFactory changeControlGenericFactory,
|
||||
ChangeData.Factory changeDataFactory,
|
||||
PatchLineCommentsUtil plcUtil,
|
||||
AccountResolver accountResolver,
|
||||
GroupBackend groupBackend,
|
||||
AllProjectsName allProjectsName,
|
||||
@@ -187,6 +190,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
||||
this.capabilityControlFactory = capabilityControlFactory;
|
||||
this.changeControlGenericFactory = changeControlGenericFactory;
|
||||
this.changeDataFactory = changeDataFactory;
|
||||
this.plcUtil = plcUtil;
|
||||
this.accountResolver = accountResolver;
|
||||
this.groupBackend = groupBackend;
|
||||
this.allProjectsName = allProjectsName;
|
||||
|
||||
@@ -33,7 +33,8 @@ class HasDraftByPredicate extends OperatorPredicate<ChangeData> implements
|
||||
private final Arguments args;
|
||||
private final Account.Id accountId;
|
||||
|
||||
HasDraftByPredicate(Arguments args, Account.Id accountId) {
|
||||
HasDraftByPredicate(Arguments args,
|
||||
Account.Id accountId) {
|
||||
super(ChangeQueryBuilder.FIELD_DRAFTBY, accountId.toString());
|
||||
this.args = args;
|
||||
this.accountId = accountId;
|
||||
@@ -41,20 +42,16 @@ class HasDraftByPredicate extends OperatorPredicate<ChangeData> implements
|
||||
|
||||
@Override
|
||||
public boolean match(final ChangeData object) throws OrmException {
|
||||
for (PatchLineComment c : object.comments()) {
|
||||
if (c.getStatus() == PatchLineComment.Status.DRAFT
|
||||
&& c.getAuthor().equals(accountId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return !args.plcUtil
|
||||
.draftByChangeAuthor(args.db.get(), object.notes(), accountId)
|
||||
.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultSet<ChangeData> read() throws OrmException {
|
||||
Set<Change.Id> ids = new HashSet<>();
|
||||
for (PatchLineComment sc : args.db.get().patchComments()
|
||||
.draftByAuthor(accountId)) {
|
||||
for (PatchLineComment sc :
|
||||
args.plcUtil.draftByAuthor(args.db.get(), accountId)) {
|
||||
ids.add(sc.getKey().getParentKey().getParentKey().getParentKey());
|
||||
}
|
||||
|
||||
|
||||
@@ -366,7 +366,7 @@ public class QueryProcessor {
|
||||
eventFactory.addComments(c, d.messages());
|
||||
if (includePatchSets) {
|
||||
for (PatchSetAttribute attribute : c.patchSets) {
|
||||
eventFactory.addPatchSetComments(attribute, d.comments());
|
||||
eventFactory.addPatchSetComments(attribute, d.publishedComments());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user