Source:
<code>public VoidResult call() throws EmailException, InvalidChangeOperationException, NoSuchChangeException, OrmException { final String ref = (branch.startsWith(Constants.R_REFS) ? "" : Constants.R_HEADS) + branch; final Change.Id changeId = patchSetId.getParentKey(); final ChangeControl control = changeControlFactory.validateFor(changeId); if (!control.canMoveTo(ref)) { throw new InvalidChangeOperationException("Permission denied moving" + " destination branch to " + branch + " for change " + changeId); } final PatchSet patch = db.patchSets().get(patchSetId); if (patch == null) { throw new NoSuchChangeException(changeId); } final ChangeMessage cmsg = new ChangeMessage(new ChangeMessage.Key(changeId, ChangeUtil .messageUUID(db)), currentUser.getAccountId(), patchSetId); final StringBuilder msgBuf = new StringBuilder("Patch set " + patchSetId.get() + ": Change destination moved to " + branch + " branch"); if (changeComment != null && changeComment.length() > 0) { msgBuf.append("\n\n"); msgBuf.append(changeComment); } cmsg.setMessage(msgBuf.toString()); final Change updatedChange = db.changes().atomicUpdate(changeId, new AtomicUpdate<Change>() { @Override public Change update(Change change) { <START> if (change.getStatus() == Change.Status.NEW <END> && change.currentPatchSetId().equals(patchSetId)) { change.setDest(new Branch.NameKey(change.getProject(), ref)); ChangeUtil.updated(change); return change; } else { return null; } } }); if (updatedChange == null) { String err = "Change is closed or patchset is not latest"; throw new InvalidChangeOperationException(err); } db.changeMessages().insert(Collections.singleton(cmsg)); ApprovalsUtil.clearCurrentPatchSetApprovals(db, updatedChange); return VoidResult.INSTANCE; }</code><technical_language>allow change destination branch if change is in DRAFT state. I for draft changes allow change destination branch</technical_language>

Target:
public VoidResult call() throws EmailException, InvalidChangeOperationException, NoSuchChangeException, OrmException { final String ref = (branch.startsWith(Constants.R_REFS) ? "" : Constants.R_HEADS) + branch; final Change.Id changeId = patchSetId.getParentKey(); final ChangeControl control = changeControlFactory.validateFor(changeId); if (!control.canMoveTo(ref)) { throw new InvalidChangeOperationException("Permission denied moving" + " destination branch to " + branch + " for change " + changeId); } final PatchSet patch = db.patchSets().get(patchSetId); if (patch == null) { throw new NoSuchChangeException(changeId); } final ChangeMessage cmsg = new ChangeMessage(new ChangeMessage.Key(changeId, ChangeUtil .messageUUID(db)), currentUser.getAccountId(), patchSetId); final StringBuilder msgBuf = new StringBuilder("Patch set " + patchSetId.get() + ": Change destination moved to " + branch + " branch"); if (changeComment != null && changeComment.length() > 0) { msgBuf.append("\n\n"); msgBuf.append(changeComment); } cmsg.setMessage(msgBuf.toString()); final Change updatedChange = db.changes().atomicUpdate(changeId, new AtomicUpdate<Change>() { @Override public Change update(Change change) { if ((change.getStatus() == Change.Status.NEW || change.getStatus() == Change.Status.DRAFT) && change.currentPatchSetId().equals(patchSetId)) { change.setDest(new Branch.NameKey(change.getProject(), ref)); ChangeUtil.updated(change); return change; } else { return null; } } }); if (updatedChange == null) { String err = "Change is closed, submitted, or patchset is not latest"; throw new InvalidChangeOperationException(err); } db.changeMessages().insert(Collections.singleton(cmsg)); ApprovalsUtil.clearCurrentPatchSetApprovals(db, updatedChange); return VoidResult.INSTANCE; }