chistedit: move patchcontents() onto state class
Differential Revision: https://phab.mercurial-scm.org/D11642