ChangeData: Rename patches to patch sets

These are different things, and ChangeData is using PatchSets rather
than Patches in this case.

Change-Id: I42d4611b34c9cefc487833bfe50c0b209b131d70
This commit is contained in:
Dave Borowitz 2015-05-07 14:13:07 -07:00
parent 444a3e6aae
commit 956b9cf4fd
9 changed files with 21 additions and 21 deletions

View File

@ -71,7 +71,7 @@ public class DeleteDraftPatchSetIT extends AbstractDaemonTest {
assertThat(c.status).isEqualTo(ChangeStatus.DRAFT);
RestResponse r = deletePatchSet(changeId, ps, adminSession);
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_NO_CONTENT);
assertThat(getChange(changeId).patches()).hasSize(1);
assertThat(getChange(changeId).patchSets()).hasSize(1);
ps = getCurrentPatchSet(changeId);
r = deletePatchSet(changeId, ps, adminSession);
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_NO_CONTENT);

View File

@ -142,7 +142,7 @@ public class ApprovalCopier {
private static TreeMap<Integer, PatchSet> getPatchSets(ChangeData cd)
throws OrmException {
Collection<PatchSet> patchSets = cd.patches();
Collection<PatchSet> patchSets = cd.patchSets();
TreeMap<Integer, PatchSet> result = Maps.newTreeMap();
for (PatchSet ps : patchSets) {
result.put(ps.getId().get(), ps);

View File

@ -863,11 +863,11 @@ public class ChangeJson {
Optional<PatchSet.Id> limitToPsId) throws OrmException {
Collection<PatchSet> src;
if (has(ALL_REVISIONS) || has(MESSAGES)) {
src = cd.patches();
src = cd.patchSets();
} else {
PatchSet ps;
if (limitToPsId.isPresent()) {
ps = cd.patch(limitToPsId.get());
ps = cd.patchSet(limitToPsId.get());
if (ps == null) {
throw new OrmException("missing patch set " + limitToPsId.get());
}

View File

@ -317,7 +317,7 @@ public class ChangeKindCacheImpl implements ChangeKindCache {
repo = repoManager.openRepository(change.getProject());
ChangeData cd = changeDataFactory.create(db, change);
Collection<PatchSet> patchSetCollection = cd.patches();
Collection<PatchSet> patchSetCollection = cd.patchSets();
PatchSet priorPs = patch;
for (PatchSet ps : patchSetCollection) {
if (ps.getId().get() < patch.getId().get() &&

View File

@ -144,7 +144,7 @@ public class GetRelated implements RestReadView<RevisionResource> {
Map<PatchSet.Id, PatchSet> r =
Maps.newHashMapWithExpectedSize(cds.size() * 2);
for (ChangeData cd : cds) {
for (PatchSet p : cd.patches()) {
for (PatchSet p : cd.patchSets()) {
r.put(p.getId(), p);
}
}

View File

@ -287,7 +287,7 @@ public class ChangeField {
public Iterable<String> get(ChangeData input, FillArgs args)
throws OrmException {
Set<String> revisions = Sets.newHashSet();
for (PatchSet ps : input.patches()) {
for (PatchSet ps : input.patchSets()) {
if (ps.getRevision() != null) {
revisions.add(ps.getRevision().get());
}

View File

@ -119,7 +119,7 @@ public class ChangeData {
public static void ensureAllPatchSetsLoaded(Iterable<ChangeData> changes)
throws OrmException {
for (ChangeData cd : changes) {
cd.patches();
cd.patchSets();
}
}
@ -127,7 +127,7 @@ public class ChangeData {
throws OrmException {
Map<PatchSet.Id, ChangeData> missing = Maps.newHashMap();
for (ChangeData cd : changes) {
if (cd.currentPatchSet == null && cd.patches == null) {
if (cd.currentPatchSet == null && cd.patchSets == null) {
missing.put(cd.change().currentPatchSetId(), cd);
}
}
@ -204,7 +204,7 @@ public class ChangeData {
private String commitMessage;
private List<FooterLine> commitFooters;
private PatchSet currentPatchSet;
private Collection<PatchSet> patches;
private Collection<PatchSet> patchSets;
private ListMultimap<PatchSet.Id, PatchSetApproval> allApprovals;
private List<PatchSetApproval> currentApprovals;
private Map<Integer, List<String>> files = new HashMap<>();
@ -468,7 +468,7 @@ public class ChangeData {
if (c == null) {
return null;
}
for (PatchSet p : patches()) {
for (PatchSet p : patchSets()) {
if (p.getId().equals(c.currentPatchSetId())) {
currentPatchSet = p;
return p;
@ -536,23 +536,23 @@ public class ChangeData {
* @return patches for the change.
* @throws OrmException an error occurred reading the database.
*/
public Collection<PatchSet> patches()
public Collection<PatchSet> patchSets()
throws OrmException {
if (patches == null) {
patches = db.patchSets().byChange(legacyId).toList();
if (patchSets == null) {
patchSets = db.patchSets().byChange(legacyId).toList();
}
return patches;
return patchSets;
}
/**
* @return patch with the given ID, or null if it does not exist.
* @return patch set with the given ID, or null if it does not exist.
* @throws OrmException an error occurred reading the database.
*/
public PatchSet patch(PatchSet.Id psId) throws OrmException {
public PatchSet patchSet(PatchSet.Id psId) throws OrmException {
if (currentPatchSet != null && currentPatchSet.getId().equals(psId)) {
return currentPatchSet;
}
for (PatchSet ps : patches()) {
for (PatchSet ps : patchSets()) {
if (ps.getId().equals(psId)) {
return ps;
}

View File

@ -32,7 +32,7 @@ class CommitPredicate extends IndexPredicate<ChangeData> {
@Override
public boolean match(final ChangeData object) throws OrmException {
for (PatchSet p : object.patches()) {
for (PatchSet p : object.patchSets()) {
if (p.getRevision() != null && p.getRevision().get() != null) {
final ObjectId id = ObjectId.fromString(p.getRevision().get());
if (abbrevId.prefixCompare(id) == 0) {

View File

@ -209,11 +209,11 @@ public class OutputStreamQuery {
if (includePatchSets) {
if (includeFiles) {
eventFactory.addPatchSets(c, d.patches(),
eventFactory.addPatchSets(c, d.patchSets(),
includeApprovals ? d.approvals().asMap() : null,
includeFiles, d.change(), labelTypes);
} else {
eventFactory.addPatchSets(c, d.patches(),
eventFactory.addPatchSets(c, d.patchSets(),
includeApprovals ? d.approvals().asMap() : null,
labelTypes);
}