Revert unsaved changes when checking out HEAD

Fix #2909.

Test Plan:

  * Edited a file. Ran `editor:checkout-head-revision` and it reverted.
  * Edited a file, saved it, then edited again. Running
    `editor:checkout-head-revision` reverts the lot.
  * Ran undo afterwards and the edits come back, so that still works.