chistedit: move makeselection() onto state class
authorMartin von Zweigbergk <martinvonz@google.com>
Tue, 12 Oct 2021 09:17:59 -0700
changeset 48209 0f498e03b016
parent 48208 7d2464b6e30b
child 48210 0444956ecbcf
chistedit: move makeselection() onto state class Differential Revision: https://phab.mercurial-scm.org/D11645
hgext/histedit.py
--- a/hgext/histedit.py	Tue Oct 12 09:16:14 2021 -0700
+++ b/hgext/histedit.py	Tue Oct 12 09:17:59 2021 -0700
@@ -1194,10 +1194,6 @@
 
 
 # ============ EVENTS ===============
-def makeselection(state, pos):
-    state.selected = pos
-
-
 def swap(state, oldpos, newpos):
     """Swap two positions and calculate necessary conflicts in
     O(|newpos-oldpos|) time"""
@@ -1218,7 +1214,7 @@
         rules[oldpos].checkconflicts(rules[r])
 
     if state.selected:
-        makeselection(state, newpos)
+        state.make_selection(newpos)
 
 
 def changeaction(state, pos, action):
@@ -1525,7 +1521,7 @@
             cycleaction(self, oldpos, next=False)
         elif action == b'select':
             selected = oldpos if selected is None else None
-            makeselection(self, selected)
+            self.make_selection(selected)
         elif action == b'goto' and int(ch) < len(rules) and len(rules) <= 10:
             newrule = next((r for r in rules if r.origpos == int(ch)))
             self.move_cursor(oldpos, newrule.pos)
@@ -1590,6 +1586,9 @@
         if mode == MODE_PATCH:
             self.modes[MODE_PATCH][b'patchcontents'] = self.patch_contents()
 
+    def make_selection(self, pos):
+        self.selected = pos
+
 
 def _chisteditmain(repo, rules, stdscr):
     try: