Show More
@@ -1194,29 +1194,6 b' class histeditrule(object):' | |||||
1194 |
|
1194 | |||
1195 |
|
1195 | |||
1196 | # ============ EVENTS =============== |
|
1196 | # ============ EVENTS =============== | |
1197 | def swap(state, oldpos, newpos): |
|
|||
1198 | """Swap two positions and calculate necessary conflicts in |
|
|||
1199 | O(|newpos-oldpos|) time""" |
|
|||
1200 |
|
||||
1201 | rules = state.rules |
|
|||
1202 | assert 0 <= oldpos < len(rules) and 0 <= newpos < len(rules) |
|
|||
1203 |
|
||||
1204 | rules[oldpos], rules[newpos] = rules[newpos], rules[oldpos] |
|
|||
1205 |
|
||||
1206 | # TODO: swap should not know about histeditrule's internals |
|
|||
1207 | rules[newpos].pos = newpos |
|
|||
1208 | rules[oldpos].pos = oldpos |
|
|||
1209 |
|
||||
1210 | start = min(oldpos, newpos) |
|
|||
1211 | end = max(oldpos, newpos) |
|
|||
1212 | for r in pycompat.xrange(start, end + 1): |
|
|||
1213 | rules[newpos].checkconflicts(rules[r]) |
|
|||
1214 | rules[oldpos].checkconflicts(rules[r]) |
|
|||
1215 |
|
||||
1216 | if state.selected: |
|
|||
1217 | state.make_selection(newpos) |
|
|||
1218 |
|
||||
1219 |
|
||||
1220 | def changeaction(state, pos, action): |
|
1197 | def changeaction(state, pos, action): | |
1221 | """Change the action state on the given position to the new action""" |
|
1198 | """Change the action state on the given position to the new action""" | |
1222 | rules = state.rules |
|
1199 | rules = state.rules | |
@@ -1509,12 +1486,12 b' pgup/K: move patch up, pgdn/J: move patc' | |||||
1509 | newpos = min(oldpos + 1, len(rules) - 1) |
|
1486 | newpos = min(oldpos + 1, len(rules) - 1) | |
1510 | self.move_cursor(oldpos, newpos) |
|
1487 | self.move_cursor(oldpos, newpos) | |
1511 | if selected is not None or action == b'move-down': |
|
1488 | if selected is not None or action == b'move-down': | |
1512 |
swap( |
|
1489 | self.swap(oldpos, newpos) | |
1513 | elif action in (b'up', b'move-up'): |
|
1490 | elif action in (b'up', b'move-up'): | |
1514 | newpos = max(0, oldpos - 1) |
|
1491 | newpos = max(0, oldpos - 1) | |
1515 | self.move_cursor(oldpos, newpos) |
|
1492 | self.move_cursor(oldpos, newpos) | |
1516 | if selected is not None or action == b'move-up': |
|
1493 | if selected is not None or action == b'move-up': | |
1517 |
swap( |
|
1494 | self.swap(oldpos, newpos) | |
1518 | elif action == b'next-action': |
|
1495 | elif action == b'next-action': | |
1519 | cycleaction(self, oldpos, next=True) |
|
1496 | cycleaction(self, oldpos, next=True) | |
1520 | elif action == b'prev-action': |
|
1497 | elif action == b'prev-action': | |
@@ -1526,7 +1503,7 b' pgup/K: move patch up, pgdn/J: move patc' | |||||
1526 | newrule = next((r for r in rules if r.origpos == int(ch))) |
|
1503 | newrule = next((r for r in rules if r.origpos == int(ch))) | |
1527 | self.move_cursor(oldpos, newrule.pos) |
|
1504 | self.move_cursor(oldpos, newrule.pos) | |
1528 | if selected is not None: |
|
1505 | if selected is not None: | |
1529 |
swap( |
|
1506 | self.swap(oldpos, newrule.pos) | |
1530 | elif action.startswith(b'action-'): |
|
1507 | elif action.startswith(b'action-'): | |
1531 | changeaction(self, oldpos, action[7:]) |
|
1508 | changeaction(self, oldpos, action[7:]) | |
1532 | elif action == b'showpatch': |
|
1509 | elif action == b'showpatch': | |
@@ -1589,6 +1566,28 b' pgup/K: move patch up, pgdn/J: move patc' | |||||
1589 | def make_selection(self, pos): |
|
1566 | def make_selection(self, pos): | |
1590 | self.selected = pos |
|
1567 | self.selected = pos | |
1591 |
|
1568 | |||
|
1569 | def swap(self, oldpos, newpos): | |||
|
1570 | """Swap two positions and calculate necessary conflicts in | |||
|
1571 | O(|newpos-oldpos|) time""" | |||
|
1572 | ||||
|
1573 | rules = self.rules | |||
|
1574 | assert 0 <= oldpos < len(rules) and 0 <= newpos < len(rules) | |||
|
1575 | ||||
|
1576 | rules[oldpos], rules[newpos] = rules[newpos], rules[oldpos] | |||
|
1577 | ||||
|
1578 | # TODO: swap should not know about histeditrule's internals | |||
|
1579 | rules[newpos].pos = newpos | |||
|
1580 | rules[oldpos].pos = oldpos | |||
|
1581 | ||||
|
1582 | start = min(oldpos, newpos) | |||
|
1583 | end = max(oldpos, newpos) | |||
|
1584 | for r in pycompat.xrange(start, end + 1): | |||
|
1585 | rules[newpos].checkconflicts(rules[r]) | |||
|
1586 | rules[oldpos].checkconflicts(rules[r]) | |||
|
1587 | ||||
|
1588 | if self.selected: | |||
|
1589 | self.make_selection(newpos) | |||
|
1590 | ||||
1592 |
|
1591 | |||
1593 | def _chisteditmain(repo, rules, stdscr): |
|
1592 | def _chisteditmain(repo, rules, stdscr): | |
1594 | try: |
|
1593 | try: |
General Comments 0
You need to be logged in to leave comments.
Login now