Patchwork D11642: chistedit: move patchcontents() onto state class

login
register
mail settings
Submitter phabricator
Date Oct. 12, 2021, 5:07 p.m.
Message ID <differential-rev-PHID-DREV-msjzhoe6hsqfb7mwcw2a-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49966/
State Superseded
Headers show

Comments

phabricator - Oct. 12, 2021, 5:07 p.m.
martinvonz created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11642

AFFECTED FILES
  hgext/histedit.py

CHANGE DETAILS




To: martinvonz, durin42, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -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: