Source:
public Response<String> apply(ChangeResource req, Input input) throws AuthException, OrmException, IOException { if (input == null) { input = new Input(); } ChangeControl control = req.getControl(); Change change = req.getChange(); if (!control.canEditTopicName()) { throw new AuthException("changing topic not permitted"); } ReviewDb db = dbProvider.get(); final String newTopicName = Strings.nullToEmpty(input.topic); String oldTopicName = Strings.nullToEmpty(change.getTopic()); if (!oldTopicName.equals(newTopicName)) { StringBuilder msgBuf = new StringBuilder() .append("Topic edited.") .append("\n\n") .append("Old topic: " + (oldTopicName.isEmpty() ? "[empty]" : oldTopicName)) .append("\n\n") .append("New topic: " + (newTopicName.isEmpty() ? "[removed]" : newTopicName)); if (!Strings.isNullOrEmpty(input.message)) { msgBuf.append("\n\n"); msgBuf.append(input.message); } IdentifiedUser currentUser = ((IdentifiedUser) control.getCurrentUser()); ChangeMessage cmsg = new ChangeMessage( new ChangeMessage.Key(change.getId(), ChangeUtil.messageUUID(db)), currentUser.getAccountId(), TimeUtil.nowTs(), change.currentPatchSetId()); cmsg.setMessage(msgBuf.toString()); db.changes().beginTransaction(change.getId()); try { change = db.changes().atomicUpdate(change.getId(), new AtomicUpdate<Change>() { @Override public Change update(Change change) { change.setTopic(Strings.emptyToNull(newTopicName)); ChangeUtil.updated(change); return change; } }); db.changeMessages().insert(Collections.singleton(cmsg)); db.commit(); } finally { db.rollback(); } CheckedFuture<?, IOException> indexFuture = indexer.indexAsync(change.getId()); hooks.doTopicChangedHook(change, currentUser.getAccount(), oldTopicName, db); indexFuture.checkedGet(); } return Strings.isNullOrEmpty(newTopicName) ? Response.<String>none() : Response.ok(newTopicName); }

Target:
public Response<String> apply(ChangeResource req, Input input) throws AuthException, OrmException, IOException { if (input == null) { input = new Input(); } ChangeControl control = req.getControl(); Change change = req.getChange(); if (!control.canEditTopicName()) { throw new AuthException("changing topic not permitted"); } ReviewDb db = dbProvider.get(); final String newTopicName = Strings.nullToEmpty(input.topic); String oldTopicName = Strings.nullToEmpty(change.getTopic()); if (!oldTopicName.equals(newTopicName)) { String summary; if (oldTopicName.isEmpty()) { summary = "Topic set to " + newTopicName; } else if (newTopicName.isEmpty()) { summary = "Topic " + oldTopicName + " removed"; } else { summary = String.format( "Topic changed from %s to %s", oldTopicName, newTopicName); } IdentifiedUser currentUser = ((IdentifiedUser) control.getCurrentUser()); ChangeMessage cmsg = new ChangeMessage( new ChangeMessage.Key(change.getId(), ChangeUtil.messageUUID(db)), currentUser.getAccountId(), TimeUtil.nowTs(), change.currentPatchSetId()); StringBuilder msgBuf = new StringBuilder(summary); if (!Strings.isNullOrEmpty(input.message)) { msgBuf.append("\n\n"); msgBuf.append(input.message); } cmsg.setMessage(msgBuf.toString()); db.changes().beginTransaction(change.getId()); try { change = db.changes().atomicUpdate(change.getId(), new AtomicUpdate<Change>() { @Override public Change update(Change change) { change.setTopic(Strings.emptyToNull(newTopicName)); ChangeUtil.updated(change); return change; } }); db.changeMessages().insert(Collections.singleton(cmsg)); db.commit(); } finally { db.rollback(); } CheckedFuture<?, IOException> indexFuture = indexer.indexAsync(change.getId()); hooks.doTopicChangedHook(change, currentUser.getAccount(), oldTopicName, db); indexFuture.checkedGet(); } return Strings.isNullOrEmpty(newTopicName) ? Response.<String>none() : Response.ok(newTopicName); }