Remove PatchSetAncestors table
The only remaining callers are the insert and delete code paths; it is no longer used for lookups. Change-Id: Id665eda39b585750f1b4032312ea04f5539456b4
This commit is contained in:
@@ -39,8 +39,6 @@ import java.util.Arrays;
|
||||
* |
|
||||
* +- {@link PatchSetApproval}: a +/- vote on the change's current state.
|
||||
* |
|
||||
* +- {@link PatchSetAncestor}: parents of this change's commit.
|
||||
* |
|
||||
* +- {@link PatchLineComment}: comment about a specific line
|
||||
* </pre>
|
||||
* <p>
|
||||
@@ -51,11 +49,6 @@ import java.util.Arrays;
|
||||
* {@link Account} is usually also listed as the author and committer in the
|
||||
* PatchSetInfo.
|
||||
* <p>
|
||||
* The {@link PatchSetAncestor} entities are a mirror of the Git commit
|
||||
* metadata, providing access to the information without needing direct
|
||||
* accessing Git. These entities are actually legacy artifacts from Gerrit 1.x
|
||||
* and could be removed, replaced by direct RevCommit access.
|
||||
* <p>
|
||||
* Each PatchSet contains zero or more Patch records, detailing the file paths
|
||||
* impacted by the change (otherwise known as, the file paths the author
|
||||
* added/deleted/modified). Sometimes a merge commit can contain zero patches,
|
||||
|
@@ -1,88 +0,0 @@
|
||||
// Copyright (C) 2008 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.reviewdb.client;
|
||||
|
||||
import com.google.gwtorm.client.Column;
|
||||
import com.google.gwtorm.client.IntKey;
|
||||
|
||||
/** Ancestors of a {@link PatchSet} that the PatchSet depends upon. */
|
||||
public final class PatchSetAncestor {
|
||||
public static class Id extends IntKey<PatchSet.Id> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Column(id = 1, name = Column.NONE)
|
||||
protected PatchSet.Id patchSetId;
|
||||
|
||||
@Column(id = 2)
|
||||
protected int position;
|
||||
|
||||
protected Id() {
|
||||
patchSetId = new PatchSet.Id();
|
||||
}
|
||||
|
||||
public Id(final PatchSet.Id psId, final int pos) {
|
||||
this.patchSetId = psId;
|
||||
this.position = pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PatchSet.Id getParentKey() {
|
||||
return patchSetId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int get() {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void set(int newValue) {
|
||||
position = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Column(id = 1, name = Column.NONE)
|
||||
protected Id key;
|
||||
|
||||
@Column(id = 2)
|
||||
protected RevId ancestorRevision;
|
||||
|
||||
protected PatchSetAncestor() {
|
||||
}
|
||||
|
||||
public PatchSetAncestor(final PatchSetAncestor.Id k) {
|
||||
key = k;
|
||||
}
|
||||
|
||||
public PatchSetAncestor.Id getId() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public PatchSet.Id getPatchSet() {
|
||||
return key.patchSetId;
|
||||
}
|
||||
|
||||
public int getPosition() {
|
||||
return key.position;
|
||||
}
|
||||
|
||||
public RevId getAncestorRevision() {
|
||||
return ancestorRevision;
|
||||
}
|
||||
|
||||
public void setAncestorRevision(final RevId id) {
|
||||
ancestorRevision = id;
|
||||
}
|
||||
}
|
@@ -1,45 +0,0 @@
|
||||
// Copyright (C) 2008 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.reviewdb.server;
|
||||
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.reviewdb.client.PatchSetAncestor;
|
||||
import com.google.gerrit.reviewdb.client.RevId;
|
||||
import com.google.gwtorm.server.Access;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.gwtorm.server.PrimaryKey;
|
||||
import com.google.gwtorm.server.Query;
|
||||
import com.google.gwtorm.server.ResultSet;
|
||||
|
||||
public interface PatchSetAncestorAccess extends
|
||||
Access<PatchSetAncestor, PatchSetAncestor.Id> {
|
||||
@Override
|
||||
@PrimaryKey("key")
|
||||
PatchSetAncestor get(PatchSetAncestor.Id key) throws OrmException;
|
||||
|
||||
@Query("WHERE key.patchSetId = ? ORDER BY key.position")
|
||||
ResultSet<PatchSetAncestor> ancestorsOf(PatchSet.Id id) throws OrmException;
|
||||
|
||||
@Query("WHERE key.patchSetId.changeId = ?")
|
||||
ResultSet<PatchSetAncestor> byChange(Change.Id id) throws OrmException;
|
||||
|
||||
@Query("WHERE key.patchSetId = ?")
|
||||
ResultSet<PatchSetAncestor> byPatchSet(PatchSet.Id id) throws OrmException;
|
||||
|
||||
@Query("WHERE ancestorRevision = ?")
|
||||
ResultSet<PatchSetAncestor> descendantsOf(RevId revision)
|
||||
throws OrmException;
|
||||
}
|
@@ -92,8 +92,7 @@ public interface ReviewDb extends Schema {
|
||||
@Relation(id = 24)
|
||||
PatchSetAccess patchSets();
|
||||
|
||||
@Relation(id = 25)
|
||||
PatchSetAncestorAccess patchSetAncestors();
|
||||
// Deleted @Relation(id = 25)
|
||||
|
||||
@Relation(id = 26)
|
||||
PatchLineCommentAccess patchComments();
|
||||
|
@@ -87,14 +87,6 @@ ON patch_comments (status, author_id);
|
||||
CREATE INDEX patch_sets_byRevision
|
||||
ON patch_sets (revision);
|
||||
|
||||
-- *********************************************************************
|
||||
-- PatchSetAncestorAccess
|
||||
-- @PrimaryKey covers: ancestorsOf
|
||||
-- covers: descendantsOf
|
||||
CREATE INDEX patch_set_ancestors_desc
|
||||
ON patch_set_ancestors (ancestor_revision);
|
||||
|
||||
|
||||
-- *********************************************************************
|
||||
-- StarredChangeAccess
|
||||
-- @PrimaryKey covers: byAccount
|
||||
|
@@ -96,15 +96,6 @@ CREATE INDEX patch_sets_byRevision
|
||||
ON patch_sets (revision)
|
||||
#
|
||||
|
||||
-- *********************************************************************
|
||||
-- PatchSetAncestorAccess
|
||||
-- @PrimaryKey covers: ancestorsOf
|
||||
-- covers: descendantsOf
|
||||
CREATE INDEX patch_set_ancestors_desc
|
||||
ON patch_set_ancestors (ancestor_revision)
|
||||
#
|
||||
|
||||
|
||||
-- *********************************************************************
|
||||
-- StarredChangeAccess
|
||||
-- @PrimaryKey covers: byAccount
|
||||
|
@@ -136,13 +136,6 @@ WHERE status = 'd';
|
||||
CREATE INDEX patch_sets_byRevision
|
||||
ON patch_sets (revision);
|
||||
|
||||
-- *********************************************************************
|
||||
-- PatchSetAncestorAccess
|
||||
-- @PrimaryKey covers: ancestorsOf
|
||||
-- covers: descendantsOf
|
||||
CREATE INDEX patch_set_ancestors_desc
|
||||
ON patch_set_ancestors (ancestor_revision);
|
||||
|
||||
-- *********************************************************************
|
||||
-- StarredChangeAccess
|
||||
-- @PrimaryKey covers: byAccount
|
||||
|
@@ -25,9 +25,7 @@ import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.reviewdb.client.PatchSetAncestor;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.reviewdb.client.RevId;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.change.ChangeInserter;
|
||||
import com.google.gerrit.server.change.ChangeMessages;
|
||||
@@ -72,7 +70,6 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -149,19 +146,6 @@ public class ChangeUtil {
|
||||
c.setLastUpdatedOn(TimeUtil.nowTs());
|
||||
}
|
||||
|
||||
public static void insertAncestors(ReviewDb db, PatchSet.Id id, RevCommit src)
|
||||
throws OrmException {
|
||||
int cnt = src.getParentCount();
|
||||
List<PatchSetAncestor> toInsert = new ArrayList<>(cnt);
|
||||
for (int p = 0; p < cnt; p++) {
|
||||
PatchSetAncestor a =
|
||||
new PatchSetAncestor(new PatchSetAncestor.Id(id, p + 1));
|
||||
a.setAncestorRevision(new RevId(src.getParent(p).getId().getName()));
|
||||
toInsert.add(a);
|
||||
}
|
||||
db.patchSetAncestors().insert(toInsert);
|
||||
}
|
||||
|
||||
public static PatchSet.Id nextPatchSetId(Map<String, Ref> allRefs,
|
||||
PatchSet.Id id) {
|
||||
PatchSet.Id next = nextPatchSetId(id);
|
||||
@@ -354,7 +338,6 @@ public class ChangeUtil {
|
||||
db.patchComments().delete(db.patchComments().byChange(changeId));
|
||||
|
||||
db.patchSetApprovals().delete(db.patchSetApprovals().byChange(changeId));
|
||||
db.patchSetAncestors().delete(db.patchSetAncestors().byChange(changeId));
|
||||
db.patchSets().delete(patchSets);
|
||||
db.changeMessages().delete(db.changeMessages().byChange(changeId));
|
||||
db.starredChanges().delete(db.starredChanges().byChange(changeId));
|
||||
@@ -461,7 +444,6 @@ public class ChangeUtil {
|
||||
// No need to delete from notedb; draft patch sets will be filtered out.
|
||||
db.patchComments().delete(db.patchComments().byPatchSet(patchSetId));
|
||||
db.patchSetApprovals().delete(db.patchSetApprovals().byPatchSet(patchSetId));
|
||||
db.patchSetAncestors().delete(db.patchSetAncestors().byPatchSet(patchSetId));
|
||||
|
||||
db.patchSets().delete(Collections.singleton(patch));
|
||||
}
|
||||
|
@@ -245,7 +245,6 @@ public class ChangeInserter extends BatchUpdate.InsertChangeOp {
|
||||
ReviewDb db = ctx.getDb();
|
||||
ChangeControl ctl = ctx.getChangeControl();
|
||||
ChangeUpdate update = ctx.getChangeUpdate();
|
||||
ChangeUtil.insertAncestors(db, patchSet.getId(), commit);
|
||||
if (patchSet.getGroups() == null) {
|
||||
patchSet.setGroups(GroupCollector.getDefaultGroups(patchSet));
|
||||
}
|
||||
|
@@ -583,8 +583,6 @@ public class ConsistencyChecker {
|
||||
// historical information.
|
||||
db.accountPatchReviews().delete(
|
||||
db.accountPatchReviews().byPatchSet(psId));
|
||||
db.patchSetAncestors().delete(
|
||||
db.patchSetAncestors().byPatchSet(psId));
|
||||
db.patchSetApprovals().delete(
|
||||
db.patchSetApprovals().byPatchSet(psId));
|
||||
db.patchComments().delete(
|
||||
|
@@ -221,7 +221,6 @@ public class PatchSetInserter extends BatchUpdate.Op {
|
||||
patchSet.setRevision(new RevId(commit.name()));
|
||||
patchSet.setDraft(draft);
|
||||
|
||||
ChangeUtil.insertAncestors(db, patchSet.getId(), commit);
|
||||
if (groups != null) {
|
||||
patchSet.setGroups(groups);
|
||||
} else {
|
||||
|
@@ -2252,7 +2252,6 @@ public class ReceiveCommits {
|
||||
return null;
|
||||
}
|
||||
|
||||
ChangeUtil.insertAncestors(db, newPatchSet.getId(), newCommit);
|
||||
if (newPatchSet.getGroups() == null) {
|
||||
newPatchSet.setGroups(GroupCollector.getCurrentGroups(db, change));
|
||||
}
|
||||
|
@@ -19,11 +19,9 @@ import com.google.gerrit.common.TimeUtil;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.reviewdb.client.PatchSetAncestor;
|
||||
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
||||
import com.google.gerrit.reviewdb.client.PatchSetInfo;
|
||||
import com.google.gerrit.reviewdb.client.RevId;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.ChangeUtil;
|
||||
import com.google.gerrit.server.git.BatchUpdate;
|
||||
import com.google.gerrit.server.git.BatchUpdate.ChangeContext;
|
||||
@@ -42,11 +40,9 @@ import com.google.gwtorm.server.OrmException;
|
||||
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.PersonIdent;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import org.eclipse.jgit.transport.ReceiveCommand;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -187,7 +183,6 @@ public class CherryPick extends SubmitStrategy {
|
||||
Change c = toMerge.change();
|
||||
ps.setGroups(GroupCollector.getCurrentGroups(args.db, c));
|
||||
args.db.patchSets().insert(Collections.singleton(ps));
|
||||
insertAncestors(args.db, ps.getId(), newCommit);
|
||||
c.setCurrentPatchSet(patchSetInfo);
|
||||
args.db.changes().update(Collections.singletonList(c));
|
||||
|
||||
@@ -247,20 +242,6 @@ public class CherryPick extends SubmitStrategy {
|
||||
}
|
||||
}
|
||||
|
||||
private static void insertAncestors(ReviewDb db, PatchSet.Id id,
|
||||
RevCommit src) throws OrmException {
|
||||
int cnt = src.getParentCount();
|
||||
List<PatchSetAncestor> toInsert = new ArrayList<>(cnt);
|
||||
for (int p = 0; p < cnt; p++) {
|
||||
PatchSetAncestor a;
|
||||
|
||||
a = new PatchSetAncestor(new PatchSetAncestor.Id(id, p + 1));
|
||||
a.setAncestorRevision(new RevId(src.getParent(p).getId().name()));
|
||||
toInsert.add(a);
|
||||
}
|
||||
db.patchSetAncestors().insert(toInsert);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Change.Id, CodeReviewCommit> getNewCommits() {
|
||||
return newCommits;
|
||||
|
@@ -32,7 +32,7 @@ import java.util.List;
|
||||
/** A version of the database schema. */
|
||||
public abstract class SchemaVersion {
|
||||
/** The current schema version. */
|
||||
public static final Class<Schema_113> C = Schema_113.class;
|
||||
public static final Class<Schema_114> C = Schema_114.class;
|
||||
|
||||
public static int getBinaryVersion() {
|
||||
return guessVersion(C);
|
||||
|
@@ -0,0 +1,25 @@
|
||||
// Copyright (C) 2015 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server.schema;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
public class Schema_114 extends SchemaVersion {
|
||||
@Inject
|
||||
Schema_114(Provider<Schema_113> prior) {
|
||||
super(prior);
|
||||
}
|
||||
}
|
@@ -30,7 +30,6 @@ import com.google.gerrit.reviewdb.server.ChangeAccess;
|
||||
import com.google.gerrit.reviewdb.server.ChangeMessageAccess;
|
||||
import com.google.gerrit.reviewdb.server.PatchLineCommentAccess;
|
||||
import com.google.gerrit.reviewdb.server.PatchSetAccess;
|
||||
import com.google.gerrit.reviewdb.server.PatchSetAncestorAccess;
|
||||
import com.google.gerrit.reviewdb.server.PatchSetApprovalAccess;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.reviewdb.server.SchemaVersionAccess;
|
||||
@@ -159,11 +158,6 @@ public class DisabledReviewDb implements ReviewDb {
|
||||
throw new AssertionError(MESSAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PatchSetAncestorAccess patchSetAncestors() {
|
||||
throw new AssertionError(MESSAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PatchLineCommentAccess patchComments() {
|
||||
throw new AssertionError(MESSAGE);
|
||||
|
Reference in New Issue
Block a user