hgext/histedit.py
changeset 48213 8ac61257c807
parent 48212 b6fc7d188f68
child 48214 9006eafa0942
equal deleted inserted replaced
48212:b6fc7d188f68 48213:8ac61257c807
  1422             MODE_PATCH: {
  1422             MODE_PATCH: {
  1423                 b'line_offset': 0,
  1423                 b'line_offset': 0,
  1424             },
  1424             },
  1425         }
  1425         }
  1426 
  1426 
       
  1427     def render_commit(self, win):
       
  1428         """Renders the commit window that shows the log of the current selected
       
  1429         commit"""
       
  1430         pos = self.pos
       
  1431         rules = self.rules
       
  1432         rule = rules[pos]
       
  1433 
       
  1434         ctx = rule.ctx
       
  1435         win.box()
       
  1436 
       
  1437         maxy, maxx = win.getmaxyx()
       
  1438         length = maxx - 3
       
  1439 
       
  1440         line = b"changeset: %d:%s" % (ctx.rev(), ctx.hex()[:12])
       
  1441         win.addstr(1, 1, line[:length])
       
  1442 
       
  1443         line = b"user:      %s" % ctx.user()
       
  1444         win.addstr(2, 1, line[:length])
       
  1445 
       
  1446         bms = self.repo.nodebookmarks(ctx.node())
       
  1447         line = b"bookmark:  %s" % b' '.join(bms)
       
  1448         win.addstr(3, 1, line[:length])
       
  1449 
       
  1450         line = b"summary:   %s" % (ctx.description().splitlines()[0])
       
  1451         win.addstr(4, 1, line[:length])
       
  1452 
       
  1453         line = b"files:     "
       
  1454         win.addstr(5, 1, line)
       
  1455         fnx = 1 + len(line)
       
  1456         fnmaxx = length - fnx + 1
       
  1457         y = 5
       
  1458         fnmaxn = maxy - (1 + y) - 1
       
  1459         files = ctx.files()
       
  1460         for i, line1 in enumerate(files):
       
  1461             if len(files) > fnmaxn and i == fnmaxn - 1:
       
  1462                 win.addstr(y, fnx, _trunc_tail(b','.join(files[i:]), fnmaxx))
       
  1463                 y = y + 1
       
  1464                 break
       
  1465             win.addstr(y, fnx, _trunc_head(line1, fnmaxx))
       
  1466             y = y + 1
       
  1467 
       
  1468         conflicts = rule.conflicts
       
  1469         if len(conflicts) > 0:
       
  1470             conflictstr = b','.join(map(lambda r: r.ctx.hex()[:12], conflicts))
       
  1471             conflictstr = b"changed files overlap with %s" % conflictstr
       
  1472         else:
       
  1473             conflictstr = b'no overlap'
       
  1474 
       
  1475         win.addstr(y, 1, conflictstr[:length])
       
  1476         win.noutrefresh()
       
  1477 
  1427 
  1478 
  1428 def _chisteditmain(repo, rules, stdscr):
  1479 def _chisteditmain(repo, rules, stdscr):
  1429     try:
  1480     try:
  1430         curses.use_default_colors()
  1481         curses.use_default_colors()
  1431     except curses.error:
  1482     except curses.error:
  1449     # don't display the cursor
  1500     # don't display the cursor
  1450     try:
  1501     try:
  1451         curses.curs_set(0)
  1502         curses.curs_set(0)
  1452     except curses.error:
  1503     except curses.error:
  1453         pass
  1504         pass
  1454 
       
  1455     def rendercommit(win, state):
       
  1456         """Renders the commit window that shows the log of the current selected
       
  1457         commit"""
       
  1458         pos = state.pos
       
  1459         rules = state.rules
       
  1460         rule = rules[pos]
       
  1461 
       
  1462         ctx = rule.ctx
       
  1463         win.box()
       
  1464 
       
  1465         maxy, maxx = win.getmaxyx()
       
  1466         length = maxx - 3
       
  1467 
       
  1468         line = b"changeset: %d:%s" % (ctx.rev(), ctx.hex()[:12])
       
  1469         win.addstr(1, 1, line[:length])
       
  1470 
       
  1471         line = b"user:      %s" % ctx.user()
       
  1472         win.addstr(2, 1, line[:length])
       
  1473 
       
  1474         bms = repo.nodebookmarks(ctx.node())
       
  1475         line = b"bookmark:  %s" % b' '.join(bms)
       
  1476         win.addstr(3, 1, line[:length])
       
  1477 
       
  1478         line = b"summary:   %s" % (ctx.description().splitlines()[0])
       
  1479         win.addstr(4, 1, line[:length])
       
  1480 
       
  1481         line = b"files:     "
       
  1482         win.addstr(5, 1, line)
       
  1483         fnx = 1 + len(line)
       
  1484         fnmaxx = length - fnx + 1
       
  1485         y = 5
       
  1486         fnmaxn = maxy - (1 + y) - 1
       
  1487         files = ctx.files()
       
  1488         for i, line1 in enumerate(files):
       
  1489             if len(files) > fnmaxn and i == fnmaxn - 1:
       
  1490                 win.addstr(y, fnx, _trunc_tail(b','.join(files[i:]), fnmaxx))
       
  1491                 y = y + 1
       
  1492                 break
       
  1493             win.addstr(y, fnx, _trunc_head(line1, fnmaxx))
       
  1494             y = y + 1
       
  1495 
       
  1496         conflicts = rule.conflicts
       
  1497         if len(conflicts) > 0:
       
  1498             conflictstr = b','.join(map(lambda r: r.ctx.hex()[:12], conflicts))
       
  1499             conflictstr = b"changed files overlap with %s" % conflictstr
       
  1500         else:
       
  1501             conflictstr = b'no overlap'
       
  1502 
       
  1503         win.addstr(y, 1, conflictstr[:length])
       
  1504         win.noutrefresh()
       
  1505 
  1505 
  1506     def helplines(mode):
  1506     def helplines(mode):
  1507         if mode == MODE_PATCH:
  1507         if mode == MODE_PATCH:
  1508             help = b"""\
  1508             help = b"""\
  1509 ?: help, k/up: line up, j/down: line down, v: stop viewing patch
  1509 ?: help, k/up: line up, j/down: line down, v: stop viewing patch
  1677                 renderpatch(mainwin, state)
  1677                 renderpatch(mainwin, state)
  1678             elif curmode == MODE_HELP:
  1678             elif curmode == MODE_HELP:
  1679                 renderstring(mainwin, state, __doc__.strip().splitlines())
  1679                 renderstring(mainwin, state, __doc__.strip().splitlines())
  1680             else:
  1680             else:
  1681                 renderrules(mainwin, state)
  1681                 renderrules(mainwin, state)
  1682                 rendercommit(commitwin, state)
  1682                 state.render_commit(commitwin)
  1683             renderhelp(helpwin, state)
  1683             renderhelp(helpwin, state)
  1684             curses.doupdate()
  1684             curses.doupdate()
  1685             # done rendering
  1685             # done rendering
  1686             ch = encoding.strtolocal(stdscr.getkey())
  1686             ch = encoding.strtolocal(stdscr.getkey())
  1687 
  1687