Source:
private boolean refresh(Change change, final PatchSet ps, Project.SubmitType type, Repository git, Map<String, Ref> refs, final Ref ref) throws IOException, OrmException { RevWalk rw = new RevWalk(git) { @Override protected CodeReviewCommit createCommit(AnyObjectId id) { return new CodeReviewCommit(id); } }; try { ObjectId id; try { id = ObjectId.fromString(ps.getRevision().get()); } catch (IllegalArgumentException e) { log.error(String.format( "Invalid revision on patch set %d of %d", ps.getId().get(), change.getId().get())); return false; } RevFlag canMerge = rw.newFlag("CAN_MERGE"); CodeReviewCommit rev = parse(rw, id); rev.add(canMerge); final boolean mergeable; if (ref == null || ref.getObjectId() == null) { mergeable = true; } else { CodeReviewCommit tip = parse(rw, ref.getObjectId()); Set<RevCommit> accepted = alreadyAccepted(rw, refs.values()); accepted.add(tip); accepted.addAll(Arrays.asList(rev.getParents())); mergeable = submitStrategyFactory.create( type, db.get(), git, rw, null , canMerge, accepted, change.getDest()).dryRun(tip, rev); } Change c = db.get().changes().atomicUpdate( change.getId(), new AtomicUpdate<Change>() { @Override public Change update(Change c) { if (c.getStatus().isOpen() && ps.getId().equals(c.currentPatchSetId())) { c.setMergeable(mergeable); c.setLastSha1MergeTested(toRevId(ref)); } return null; } }); if (c != null) { indexer.index(db.get(), c); } return mergeable; } catch (MergeException | IOException | NoSuchProjectException e) { log.error(String.format( "Cannot merge test change %d", change.getId().get()), e); return false; } finally { rw.release(); } }

Target:
private boolean refresh(Change change, final PatchSet ps, Project.SubmitType type, Repository git, Map<String, Ref> refs, final Ref ref) throws IOException, OrmException { RevWalk rw = new RevWalk(git) { @Override protected CodeReviewCommit createCommit(AnyObjectId id) { return new CodeReviewCommit(id); } }; try { ObjectId id; try { id = ObjectId.fromString(ps.getRevision().get()); } catch (IllegalArgumentException e) { log.error(String.format( "Invalid revision on patch set %d of %d", ps.getId().get(), change.getId().get())); return false; } RevFlag canMerge = rw.newFlag("CAN_MERGE"); CodeReviewCommit rev = parse(rw, id); rev.add(canMerge); final boolean mergeable; if (ref == null || ref.getObjectId() == null) { mergeable = true; } else { CodeReviewCommit tip = parse(rw, ref.getObjectId()); Set<RevCommit> accepted = alreadyAccepted(rw, refs.values()); accepted.add(tip); accepted.addAll(Arrays.asList(rev.getParents())); mergeable = submitStrategyFactory.create( type, db.get(), git, rw, null , canMerge, accepted, change.getDest()).dryRun(tip, rev); } Change c = db.get().changes().atomicUpdate( change.getId(), new AtomicUpdate<Change>() { @Override public Change update(Change c) { if (c.getStatus().isOpen() && ps.getId().equals(c.currentPatchSetId())) { c.setMergeable(mergeable); c.setLastSha1MergeTested(toRevId(ref)); return c; } else { return null; } } }); if (c != null) { indexer.index(db.get(), c); } return mergeable; } catch (MergeException | IOException | NoSuchProjectException e) { log.error(String.format( "Cannot merge test change %d", change.getId().get()), e); return false; } finally { rw.release(); } }