comparison mercurial/crecord.py @ 25556:40f0e9e5b821

crecord: add mechanism for error reporting Before this patch, there was no way to report errors in the crecord ui. This patch introduces a new variable errorstr. If set, its content replaces the top banner displayed in crecord until a key is pressed.
author Laurent Charignon <lcharignon@fb.com>
date Fri, 05 Jun 2015 13:53:49 -0700
parents 838fa1932ff8
children 52c552a05414
comparison
equal deleted inserted replaced
25555:838fa1932ff8 25556:40f0e9e5b821
509 # put the headers into a patch object 509 # put the headers into a patch object
510 self.headerlist = patch(headerlist) 510 self.headerlist = patch(headerlist)
511 511
512 self.ui = ui 512 self.ui = ui
513 513
514 self.errorstr = None
514 # list of all chunks 515 # list of all chunks
515 self.chunklist = [] 516 self.chunklist = []
516 for h in headerlist: 517 for h in headerlist:
517 self.chunklist.append(h) 518 self.chunklist.append(h)
518 self.chunklist.extend(h.hunks) 519 self.chunklist.extend(h.hunks)
974 975
975 printstring = self.printstring 976 printstring = self.printstring
976 977
977 # print out the status lines at the top 978 # print out the status lines at the top
978 try: 979 try:
980 if self.errorstr is not None:
981 printstring(self.statuswin, self.errorstr, pairname='legend')
982 printstring(self.statuswin, 'Press any key to continue',
983 pairname='legend')
984 self.statuswin.refresh()
985 return
979 printstring(self.statuswin, 986 printstring(self.statuswin,
980 "SELECT CHUNKS: (j/k/up/dn/pgup/pgdn) move cursor; " 987 "SELECT CHUNKS: (j/k/up/dn/pgup/pgdn) move cursor; "
981 "(space/A) toggle hunk/all; (e)dit hunk;", 988 "(space/A) toggle hunk/all; (e)dit hunk;",
982 pairname="legend") 989 pairname="legend")
983 printstring(self.statuswin, 990 printstring(self.statuswin,
1599 1606
1600 while True: 1607 while True:
1601 self.updatescreen() 1608 self.updatescreen()
1602 try: 1609 try:
1603 keypressed = self.statuswin.getkey() 1610 keypressed = self.statuswin.getkey()
1611 if self.errorstr is not None:
1612 self.errorstr = None
1613 continue
1604 except curses.error: 1614 except curses.error:
1605 keypressed = "foobar" 1615 keypressed = "foobar"
1606 if self.handlekeypressed(keypressed): 1616 if self.handlekeypressed(keypressed):
1607 break 1617 break