From patchwork Tue Oct 12 17:07:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D11647: chistedit: move changeaction() onto state class From: phabricator X-Patchwork-Id: 49971 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Tue, 12 Oct 2021 17:07:16 +0000 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 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: