# HG changeset patch # User Martin von Zweigbergk # Date 1634054216 25200 # Node ID c7690fabce5f3e661a951c5baf3591803298288b # Parent 3fdeb657602fabdd3f2fa53dff68f679512b550c chistedit: move patchcontents() onto state class Differential Revision: https://phab.mercurial-scm.org/D11642 diff -r 3fdeb657602f -r c7690fabce5f hgext/histedit.py --- a/hgext/histedit.py Tue Oct 12 08:55:19 2021 -0700 +++ b/hgext/histedit.py Tue Oct 12 08:56:56 2021 -0700 @@ -1218,7 +1218,7 @@ curmode, _ = state.mode state.mode = (mode, curmode) if mode == MODE_PATCH: - state.modes[MODE_PATCH][b'patchcontents'] = patchcontents(state) + state.modes[MODE_PATCH][b'patchcontents'] = state.patch_contents() def makeselection(state, pos): @@ -1325,19 +1325,6 @@ return line[: n - 2] + b' >' -def patchcontents(state): - repo = state.repo - rule = state.rules[state.pos] - displayer = logcmdutil.changesetdisplayer( - repo.ui, repo, {b"patch": True, b"template": b"status"}, buffered=True - ) - overrides = {(b'ui', b'verbose'): True} - with repo.ui.configoverride(overrides, source=b'histedit'): - displayer.show(rule.ctx) - displayer.close() - return displayer.hunk[rule.ctx.rev()].splitlines() - - class _chistedit_state(object): def __init__( self, @@ -1590,6 +1577,21 @@ elif action == b'line-up': return E_LINEUP + def patch_contents(self): + repo = self.repo + rule = self.rules[self.pos] + displayer = logcmdutil.changesetdisplayer( + repo.ui, + repo, + {b"patch": True, b"template": b"status"}, + buffered=True, + ) + overrides = {(b'ui', b'verbose'): True} + with repo.ui.configoverride(overrides, source=b'histedit'): + displayer.show(rule.ctx) + displayer.close() + return displayer.hunk[rule.ctx.rev()].splitlines() + def _chisteditmain(repo, rules, stdscr): try: