##// END OF EJS Templates
chistedit: add option to show order of commits in opposite order...
Martin von Zweigbergk -
r49047:c820866c default
parent child Browse files
Show More
@@ -282,6 +282,11 b' configitem('
282 282 default=None,
283 283 )
284 284 configitem(b'histedit', b'summary-template', default=b'{rev} {desc|firstline}')
285 # TODO: Teach the text-based histedit interface to respect this config option
286 # before we make it non-experimental.
287 configitem(
288 b'histedit', b'later-commits-first', default=False, experimental=True
289 )
285 290
286 291 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
287 292 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
@@ -1240,6 +1245,11 b' class _chistedit_state(object):'
1240 1245 self.repo = repo
1241 1246 self.rules = rules
1242 1247 self.stdscr = stdscr
1248 self.later_on_top = repo.ui.configbool(
1249 b'histedit', b'later-commits-first'
1250 )
1251 # The current item in display order, initialized to point to the top
1252 # of the screen.
1243 1253 self.pos = 0
1244 1254 self.selected = None
1245 1255 self.mode = (MODE_INIT, MODE_INIT)
@@ -1256,7 +1266,7 b' class _chistedit_state(object):'
1256 1266 def render_commit(self, win):
1257 1267 """Renders the commit window that shows the log of the current selected
1258 1268 commit"""
1259 rule = self.rules[self.pos]
1269 rule = self.rules[self.display_pos_to_rule_pos(self.pos)]
1260 1270
1261 1271 ctx = rule.ctx
1262 1272 win.box()
@@ -1342,6 +1352,19 b' pgup/K: move patch up, pgdn/J: move patc'
1342 1352 b'main': (mainlen, maxx),
1343 1353 }
1344 1354
1355 def display_pos_to_rule_pos(self, display_pos):
1356 """Converts a position in display order to rule order.
1357
1358 The `display_pos` is the order from the top in display order, not
1359 considering which items are currently visible on the screen. Thus,
1360 `display_pos=0` is the item at the top (possibly after scrolling to
1361 the top)
1362 """
1363 if self.later_on_top:
1364 return len(self.rules) - 1 - display_pos
1365 else:
1366 return display_pos
1367
1345 1368 def render_rules(self, rulesscr):
1346 1369 start = self.modes[MODE_RULES][b'line_offset']
1347 1370
@@ -1352,18 +1375,21 b' pgup/K: move patch up, pgdn/J: move patc'
1352 1375 )
1353 1376 addln(rulesscr, -1, 0, line, curses.color_pair(COLOR_WARN))
1354 1377
1355 for y, rule in enumerate(self.rules[start:]):
1356 if y >= self.page_height:
1357 break
1378 for display_pos in range(start, len(self.rules)):
1379 y = display_pos - start
1380 if y < 0 or y >= self.page_height:
1381 continue
1382 rule_pos = self.display_pos_to_rule_pos(display_pos)
1383 rule = self.rules[rule_pos]
1358 1384 if len(rule.conflicts) > 0:
1359 1385 rulesscr.addstr(y, 0, b" ", curses.color_pair(COLOR_WARN))
1360 1386 else:
1361 1387 rulesscr.addstr(y, 0, b" ", curses.COLOR_BLACK)
1362 1388
1363 if y + start == self.selected:
1389 if display_pos == self.selected:
1364 1390 rollcolor = COLOR_ROLL_SELECTED
1365 1391 addln(rulesscr, y, 2, rule, curses.color_pair(COLOR_SELECTED))
1366 elif y + start == self.pos:
1392 elif display_pos == self.pos:
1367 1393 rollcolor = COLOR_ROLL_CURRENT
1368 1394 addln(
1369 1395 rulesscr,
@@ -1477,7 +1503,7 b' pgup/K: move patch up, pgdn/J: move patc'
1477 1503
1478 1504 def patch_contents(self):
1479 1505 repo = self.repo
1480 rule = self.rules[self.pos]
1506 rule = self.rules[self.display_pos_to_rule_pos(self.pos)]
1481 1507 displayer = logcmdutil.changesetdisplayer(
1482 1508 repo.ui,
1483 1509 repo,
@@ -1521,21 +1547,26 b' pgup/K: move patch up, pgdn/J: move patc'
1521 1547 def swap(self, oldpos, newpos):
1522 1548 """Swap two positions and calculate necessary conflicts in
1523 1549 O(|newpos-oldpos|) time"""
1550 old_rule_pos = self.display_pos_to_rule_pos(oldpos)
1551 new_rule_pos = self.display_pos_to_rule_pos(newpos)
1524 1552
1525 1553 rules = self.rules
1526 assert 0 <= oldpos < len(rules) and 0 <= newpos < len(rules)
1527
1528 rules[oldpos], rules[newpos] = rules[newpos], rules[oldpos]
1554 assert 0 <= old_rule_pos < len(rules) and 0 <= new_rule_pos < len(rules)
1555
1556 rules[old_rule_pos], rules[new_rule_pos] = (
1557 rules[new_rule_pos],
1558 rules[old_rule_pos],
1559 )
1529 1560
1530 1561 # TODO: swap should not know about histeditrule's internals
1531 rules[newpos].pos = newpos
1532 rules[oldpos].pos = oldpos
1533
1534 start = min(oldpos, newpos)
1535 end = max(oldpos, newpos)
1562 rules[new_rule_pos].pos = new_rule_pos
1563 rules[old_rule_pos].pos = old_rule_pos
1564
1565 start = min(old_rule_pos, new_rule_pos)
1566 end = max(old_rule_pos, new_rule_pos)
1536 1567 for r in pycompat.xrange(start, end + 1):
1537 rules[newpos].checkconflicts(rules[r])
1538 rules[oldpos].checkconflicts(rules[r])
1568 rules[new_rule_pos].checkconflicts(rules[r])
1569 rules[old_rule_pos].checkconflicts(rules[r])
1539 1570
1540 1571 if self.selected:
1541 1572 self.make_selection(newpos)
General Comments 0
You need to be logged in to leave comments. Login now