Patchwork D11647: chistedit: move changeaction() onto state class

login
register
mail settings
Submitter phabricator
Date Oct. 12, 2021, 5:07 p.m.
Message ID <differential-rev-PHID-DREV-dgjinnk5nkfjqm42ndgb-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49971/
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/D11647

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
@@ -1194,13 +1194,6 @@ 
 
 
 # ============ EVENTS ===============
-def changeaction(state, pos, action):
-    """Change the action state on the given position to the new action"""
-    rules = state.rules
-    assert 0 <= pos < len(rules)
-    rules[pos].action = action
-
-
 def cycleaction(state, pos, next=False):
     """Changes the action state the next or the previous action from
     the action list"""
@@ -1215,7 +1208,7 @@ 
         index += 1
     else:
         index -= 1
-    changeaction(state, pos, KEY_LIST[index % len(KEY_LIST)])
+    state.change_action(pos, KEY_LIST[index % len(KEY_LIST)])
 
 
 def changeview(state, delta, unit):
@@ -1505,7 +1498,7 @@ 
             if selected is not None:
                 self.swap(oldpos, newrule.pos)
         elif action.startswith(b'action-'):
-            changeaction(self, oldpos, action[7:])
+            self.change_action(oldpos, action[7:])
         elif action == b'showpatch':
             self.change_mode(MODE_PATCH if curmode != MODE_PATCH else prevmode)
         elif action == b'help':
@@ -1588,6 +1581,12 @@ 
         if self.selected:
             self.make_selection(newpos)
 
+    def change_action(self, pos, action):
+        """Change the action state on the given position to the new action"""
+        rules = self.rules
+        assert 0 <= pos < len(rules)
+        rules[pos].action = action
+
 
 def _chisteditmain(repo, rules, stdscr):
     try: