Remove the replaceByCommit map in ReceiveCommits

This map is not strictly necessary and can be removed to simplify the
logic. At one point in time the map was created to prevent a user
from uploading the same commit onto multiple changes, but this is
rather implausible with today's usage of Gerrit.

The primary location that might try to trigger this map check is
during processing of refs/for/{branch}. However, commits are visited
only once during this traversal as RevWalk tracks its output and never
produces the same commit again.

Change-Id: I7aef7b4eee8fa66fd8971fb19777fdc3685aa436
This commit is contained in:
Shawn Pearce
2014-10-17 14:31:38 -07:00
parent 4d48626b92
commit e154dbd9f6

View File

@@ -315,8 +315,6 @@ public class ReceiveCommits {
private List<CreateRequest> newChanges = Collections.emptyList();
private final Map<Change.Id, ReplaceRequest> replaceByChange =
new HashMap<>();
private final Map<RevCommit, ReplaceRequest> replaceByCommit =
new HashMap<>();
private final Set<RevCommit> validCommits = new HashSet<>();
private ListMultimap<Change.Id, Ref> refsByChange;
@@ -1458,12 +1456,7 @@ public class ReceiveCommits {
reject(cmd, "duplicate request");
return false;
}
if (replaceByCommit.containsKey(req.newCommit)) {
reject(cmd, "duplicate request");
return false;
}
replaceByChange.put(req.ontoChange, req);
replaceByCommit.put(req.newCommit, req);
return true;
}
@@ -1500,9 +1493,7 @@ public class ReceiveCommits {
if (c == null) {
break;
}
if (existing.contains(c) || replaceByCommit.containsKey(c)) {
// This commit was already scheduled to replace an existing PatchSet.
//
if (existing.contains(c)) { // Commit is already tracked.
continue;
}
@@ -1781,7 +1772,6 @@ public class ReceiveCommits {
req.validate(false);
if (req.skip && req.cmd == null) {
itr.remove();
replaceByCommit.remove(req.newCommit);
}
}
}