Show More
@@ -197,17 +197,21 b' def setupwrapcolorwrite(ui):' | |||||
197 | return oldwrite |
|
197 | return oldwrite | |
198 |
|
198 | |||
199 | def filterchunks(ui, originalhunks, usecurses, testfile, operation=None): |
|
199 | def filterchunks(ui, originalhunks, usecurses, testfile, operation=None): | |
200 | if usecurses: |
|
200 | try: | |
201 |
if |
|
201 | if usecurses: | |
202 | recordfn = crecordmod.testdecorator(testfile, |
|
202 | if testfile: | |
203 | crecordmod.testchunkselector) |
|
203 | recordfn = crecordmod.testdecorator( | |
204 | else: |
|
204 | testfile, crecordmod.testchunkselector) | |
205 | recordfn = crecordmod.chunkselector |
|
205 | else: | |
206 |
|
206 | recordfn = crecordmod.chunkselector | ||
207 | return crecordmod.filterpatch(ui, originalhunks, recordfn, operation) |
|
207 | ||
208 |
|
208 | return crecordmod.filterpatch(ui, originalhunks, recordfn, | ||
209 | else: |
|
209 | operation) | |
210 | return patch.filterpatch(ui, originalhunks, operation) |
|
210 | except crecordmod.fallbackerror as e: | |
|
211 | ui.warn('%s\n' % e.message) | |||
|
212 | ui.warn(_('falling back to text mode\n')) | |||
|
213 | ||||
|
214 | return patch.filterpatch(ui, originalhunks, operation) | |||
211 |
|
215 | |||
212 | def recordfilter(ui, originalhunks, operation=None): |
|
216 | def recordfilter(ui, originalhunks, operation=None): | |
213 | """ Prompts the user to filter the originalhunks and return a list of |
|
217 | """ Prompts the user to filter the originalhunks and return a list of |
@@ -65,6 +65,11 b' except ImportError:' | |||||
65 | # compiled with curses |
|
65 | # compiled with curses | |
66 | curses = False |
|
66 | curses = False | |
67 |
|
67 | |||
|
68 | class fallbackerror(error.Abort): | |||
|
69 | """Error that indicates the client should try to fallback to text mode.""" | |||
|
70 | # Inherits from error.Abort so that existing behavior is preserved if the | |||
|
71 | # calling code does not know how to fallback. | |||
|
72 | ||||
68 | def checkcurses(ui): |
|
73 | def checkcurses(ui): | |
69 | """Return True if the user wants to use curses |
|
74 | """Return True if the user wants to use curses | |
70 |
|
75 | |||
@@ -529,8 +534,8 b' def chunkselector(ui, headerlist, operat' | |||||
529 | origsigtstp = signal.getsignal(signal.SIGTSTP) |
|
534 | origsigtstp = signal.getsignal(signal.SIGTSTP) | |
530 | try: |
|
535 | try: | |
531 | curses.wrapper(chunkselector.main) |
|
536 | curses.wrapper(chunkselector.main) | |
532 |
if chunkselector.inite |
|
537 | if chunkselector.initexc is not None: | |
533 |
raise |
|
538 | raise chunkselector.initexc | |
534 | # ncurses does not restore signal handler for SIGTSTP |
|
539 | # ncurses does not restore signal handler for SIGTSTP | |
535 | finally: |
|
540 | finally: | |
536 | if origsigtstp is not sentinel: |
|
541 | if origsigtstp is not sentinel: | |
@@ -1718,7 +1723,7 b' are you sure you want to review/edit and' | |||||
1718 | self.stdscr = stdscr |
|
1723 | self.stdscr = stdscr | |
1719 | # error during initialization, cannot be printed in the curses |
|
1724 | # error during initialization, cannot be printed in the curses | |
1720 | # interface, it should be printed by the calling code |
|
1725 | # interface, it should be printed by the calling code | |
1721 |
self.inite |
|
1726 | self.initexc = None | |
1722 | self.yscreensize, self.xscreensize = self.stdscr.getmaxyx() |
|
1727 | self.yscreensize, self.xscreensize = self.stdscr.getmaxyx() | |
1723 |
|
1728 | |||
1724 | curses.start_color() |
|
1729 | curses.start_color() | |
@@ -1751,7 +1756,8 b' are you sure you want to review/edit and' | |||||
1751 | try: |
|
1756 | try: | |
1752 | self.chunkpad = curses.newpad(self.numpadlines, self.xscreensize) |
|
1757 | self.chunkpad = curses.newpad(self.numpadlines, self.xscreensize) | |
1753 | except curses.error: |
|
1758 | except curses.error: | |
1754 | self.initerr = _('this diff is too large to be displayed') |
|
1759 | self.initexc = fallbackerror( | |
|
1760 | _('this diff is too large to be displayed')) | |||
1755 | return |
|
1761 | return | |
1756 | # initialize selecteditemendline (initial start-line is 0) |
|
1762 | # initialize selecteditemendline (initial start-line is 0) | |
1757 | self.selecteditemendline = self.getnumlinesdisplayed( |
|
1763 | self.selecteditemendline = self.getnumlinesdisplayed( |
General Comments 0
You need to be logged in to leave comments.
Login now