Patchwork D11645: chistedit: move makeselection() onto state class

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

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,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: