Merge "Fix: push bypass review cannot close change from UI" into stable-2.6

This commit is contained in:
Shawn Pearce
2013-06-04 11:55:43 +00:00
committed by Gerrit Code Review

View File

@@ -30,11 +30,13 @@ import com.google.common.base.Function;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.LinkedListMultimap; import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.ListMultimap; import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.SetMultimap;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.Futures;
@@ -276,7 +278,7 @@ public class ReceiveCommits {
new HashMap<RevCommit, ReplaceRequest>(); new HashMap<RevCommit, ReplaceRequest>();
private final Set<RevCommit> validCommits = new HashSet<RevCommit>(); private final Set<RevCommit> validCommits = new HashSet<RevCommit>();
private Map<ObjectId, Ref> refsById; private SetMultimap<ObjectId, Ref> refsById;
private Map<String, Ref> allRefs; private Map<String, Ref> allRefs;
private final SubmoduleOp.Factory subOpFactory; private final SubmoduleOp.Factory subOpFactory;
@@ -2011,20 +2013,22 @@ public class ReceiveCommits {
rw.markUninteresting(rw.parseCommit(cmd.getOldId())); rw.markUninteresting(rw.parseCommit(cmd.getOldId()));
} }
final Map<ObjectId, Ref> byCommit = changeRefsById(); final SetMultimap<ObjectId, Ref> byCommit = changeRefsById();
final Map<Change.Key, Change.Id> byKey = openChangesByKey( final Map<Change.Key, Change.Id> byKey = openChangesByKey(
new Branch.NameKey(project.getNameKey(), cmd.getRefName())); new Branch.NameKey(project.getNameKey(), cmd.getRefName()));
final List<ReplaceRequest> toClose = new ArrayList<ReplaceRequest>(); final List<ReplaceRequest> toClose = new ArrayList<ReplaceRequest>();
RevCommit c; RevCommit c;
while ((c = rw.next()) != null) { while ((c = rw.next()) != null) {
final Ref ref = byCommit.get(c.copy()); final Set<Ref> refs = byCommit.get(c.copy());
if (ref != null) { for (Ref ref : refs) {
rw.parseBody(c); if (ref != null) {
Change.Key closedChange = rw.parseBody(c);
closeChange(cmd, PatchSet.Id.fromRef(ref.getName()), c); Change.Key closedChange =
closeProgress.update(1); closeChange(cmd, PatchSet.Id.fromRef(ref.getName()), c);
if (closedChange != null) { closeProgress.update(1);
byKey.remove(closedChange); if (closedChange != null) {
byKey.remove(closedChange);
}
} }
} }
@@ -2104,9 +2108,9 @@ public class ReceiveCommits {
return change.getKey(); return change.getKey();
} }
private Map<ObjectId, Ref> changeRefsById() throws IOException { private SetMultimap<ObjectId, Ref> changeRefsById() throws IOException {
if (refsById == null) { if (refsById == null) {
refsById = new HashMap<ObjectId, Ref>(); refsById = HashMultimap.create();
for (Ref r : repo.getRefDatabase().getRefs("refs/changes/").values()) { for (Ref r : repo.getRefDatabase().getRefs("refs/changes/").values()) {
if (PatchSet.isRef(r.getName())) { if (PatchSet.isRef(r.getName())) {
refsById.put(r.getObjectId(), r); refsById.put(r.getObjectId(), r);