Show More
@@ -77,7 +77,6 b' class patchnode(object):' | |||||
77 | Return the closest next item of the same type where there are no items |
|
77 | Return the closest next item of the same type where there are no items | |
78 | of different types between the current item and this closest item. |
|
78 | of different types between the current item and this closest item. | |
79 | If no such item exists, return None. |
|
79 | If no such item exists, return None. | |
80 |
|
||||
81 | """ |
|
80 | """ | |
82 | raise NotImplementedError("method must be implemented by subclass") |
|
81 | raise NotImplementedError("method must be implemented by subclass") | |
83 |
|
82 | |||
@@ -86,7 +85,6 b' class patchnode(object):' | |||||
86 | Return the closest previous item of the same type where there are no |
|
85 | Return the closest previous item of the same type where there are no | |
87 | items of different types between the current item and this closest item. |
|
86 | items of different types between the current item and this closest item. | |
88 | If no such item exists, return None. |
|
87 | If no such item exists, return None. | |
89 |
|
||||
90 | """ |
|
88 | """ | |
91 | raise NotImplementedError("method must be implemented by subclass") |
|
89 | raise NotImplementedError("method must be implemented by subclass") | |
92 |
|
90 | |||
@@ -109,7 +107,6 b' class patchnode(object):' | |||||
109 | the next item. |
|
107 | the next item. | |
110 |
|
108 | |||
111 | If it is not possible to get the next item, return None. |
|
109 | If it is not possible to get the next item, return None. | |
112 |
|
||||
113 | """ |
|
110 | """ | |
114 | try: |
|
111 | try: | |
115 | itemfolded = self.folded |
|
112 | itemfolded = self.folded | |
@@ -163,7 +160,6 b' class patchnode(object):' | |||||
163 | next item. |
|
160 | next item. | |
164 |
|
161 | |||
165 | If it is not possible to get the previous item, return None. |
|
162 | If it is not possible to get the previous item, return None. | |
166 |
|
||||
167 | """ |
|
163 | """ | |
168 | if constrainlevel: |
|
164 | if constrainlevel: | |
169 | return self.prevsibling() |
|
165 | return self.prevsibling() | |
@@ -190,7 +186,6 b' class patchnode(object):' | |||||
190 | class patch(patchnode, list): # todo: rename patchroot |
|
186 | class patch(patchnode, list): # todo: rename patchroot | |
191 | """ |
|
187 | """ | |
192 | list of header objects representing the patch. |
|
188 | list of header objects representing the patch. | |
193 |
|
||||
194 | """ |
|
189 | """ | |
195 | def __init__(self, headerlist): |
|
190 | def __init__(self, headerlist): | |
196 | self.extend(headerlist) |
|
191 | self.extend(headerlist) | |
@@ -487,7 +482,6 b' def gethw():' | |||||
487 | this is a rip-off of a rip-off - taken from the bpython code. it is |
|
482 | this is a rip-off of a rip-off - taken from the bpython code. it is | |
488 | useful / necessary because otherwise curses.initscr() must be called, |
|
483 | useful / necessary because otherwise curses.initscr() must be called, | |
489 | which can leave the terminal in a nasty state after exiting. |
|
484 | which can leave the terminal in a nasty state after exiting. | |
490 |
|
||||
491 | """ |
|
485 | """ | |
492 | h, w = struct.unpack( |
|
486 | h, w = struct.unpack( | |
493 | "hhhh", fcntl.ioctl(_origstdout, termios.TIOCGWINSZ, "\000"*8))[0:2] |
|
487 | "hhhh", fcntl.ioctl(_origstdout, termios.TIOCGWINSZ, "\000"*8))[0:2] | |
@@ -497,7 +491,6 b' def chunkselector(ui, headerlist):' | |||||
497 | """ |
|
491 | """ | |
498 | curses interface to get selection of chunks, and mark the applied flags |
|
492 | curses interface to get selection of chunks, and mark the applied flags | |
499 | of the chosen chunks. |
|
493 | of the chosen chunks. | |
500 |
|
||||
501 | """ |
|
494 | """ | |
502 | ui.write(_('starting interactive selection\n')) |
|
495 | ui.write(_('starting interactive selection\n')) | |
503 | chunkselector = curseschunkselector(headerlist, ui) |
|
496 | chunkselector = curseschunkselector(headerlist, ui) | |
@@ -518,7 +511,6 b' def testchunkselector(testfn, ui, header' | |||||
518 | """ |
|
511 | """ | |
519 | test interface to get selection of chunks, and mark the applied flags |
|
512 | test interface to get selection of chunks, and mark the applied flags | |
520 | of the chosen chunks. |
|
513 | of the chosen chunks. | |
521 |
|
||||
522 | """ |
|
514 | """ | |
523 | chunkselector = curseschunkselector(headerlist, ui) |
|
515 | chunkselector = curseschunkselector(headerlist, ui) | |
524 | if testfn and os.path.exists(testfn): |
|
516 | if testfn and os.path.exists(testfn): | |
@@ -595,7 +587,6 b' class curseschunkselector(object):' | |||||
595 |
|
587 | |||
596 | if the currently selected item is already at the top of the screen, |
|
588 | if the currently selected item is already at the top of the screen, | |
597 | scroll the screen down to show the new-selected item. |
|
589 | scroll the screen down to show the new-selected item. | |
598 |
|
||||
599 | """ |
|
590 | """ | |
600 | currentitem = self.currentselecteditem |
|
591 | currentitem = self.currentselecteditem | |
601 |
|
592 | |||
@@ -616,7 +607,6 b' class curseschunkselector(object):' | |||||
616 |
|
607 | |||
617 | if the currently selected item is already at the top of the screen, |
|
608 | if the currently selected item is already at the top of the screen, | |
618 | scroll the screen down to show the new-selected item. |
|
609 | scroll the screen down to show the new-selected item. | |
619 |
|
||||
620 | """ |
|
610 | """ | |
621 | currentitem = self.currentselecteditem |
|
611 | currentitem = self.currentselecteditem | |
622 | nextitem = currentitem.previtem() |
|
612 | nextitem = currentitem.previtem() | |
@@ -640,7 +630,6 b' class curseschunkselector(object):' | |||||
640 |
|
630 | |||
641 | if the currently selected item is already at the bottom of the screen, |
|
631 | if the currently selected item is already at the bottom of the screen, | |
642 | scroll the screen up to show the new-selected item. |
|
632 | scroll the screen up to show the new-selected item. | |
643 |
|
||||
644 | """ |
|
633 | """ | |
645 | #self.startprintline += 1 #debug |
|
634 | #self.startprintline += 1 #debug | |
646 | currentitem = self.currentselecteditem |
|
635 | currentitem = self.currentselecteditem | |
@@ -657,7 +646,6 b' class curseschunkselector(object):' | |||||
657 | if the cursor is already at the bottom chunk, scroll the screen up and |
|
646 | if the cursor is already at the bottom chunk, scroll the screen up and | |
658 | move the cursor-position to the subsequent chunk. otherwise, only move |
|
647 | move the cursor-position to the subsequent chunk. otherwise, only move | |
659 | the cursor position down one chunk. |
|
648 | the cursor position down one chunk. | |
660 |
|
||||
661 | """ |
|
649 | """ | |
662 | # todo: update docstring |
|
650 | # todo: update docstring | |
663 |
|
651 | |||
@@ -680,7 +668,6 b' class curseschunkselector(object):' | |||||
680 | def rightarrowevent(self): |
|
668 | def rightarrowevent(self): | |
681 | """ |
|
669 | """ | |
682 | select (if possible) the first of this item's child-items. |
|
670 | select (if possible) the first of this item's child-items. | |
683 |
|
||||
684 | """ |
|
671 | """ | |
685 | currentitem = self.currentselecteditem |
|
672 | currentitem = self.currentselecteditem | |
686 | nextitem = currentitem.firstchild() |
|
673 | nextitem = currentitem.firstchild() | |
@@ -700,7 +687,6 b' class curseschunkselector(object):' | |||||
700 | if the current item can be folded (i.e. it is an unfolded header or |
|
687 | if the current item can be folded (i.e. it is an unfolded header or | |
701 | hunk), then fold it. otherwise try select (if possible) the parent |
|
688 | hunk), then fold it. otherwise try select (if possible) the parent | |
702 | of this item. |
|
689 | of this item. | |
703 |
|
||||
704 | """ |
|
690 | """ | |
705 | currentitem = self.currentselecteditem |
|
691 | currentitem = self.currentselecteditem | |
706 |
|
692 | |||
@@ -725,7 +711,6 b' class curseschunkselector(object):' | |||||
725 | """ |
|
711 | """ | |
726 | select the header of the current item (or fold current item if the |
|
712 | select the header of the current item (or fold current item if the | |
727 | current item is already a header). |
|
713 | current item is already a header). | |
728 |
|
||||
729 | """ |
|
714 | """ | |
730 | currentitem = self.currentselecteditem |
|
715 | currentitem = self.currentselecteditem | |
731 |
|
716 | |||
@@ -775,7 +760,6 b' class curseschunkselector(object):' | |||||
775 | """ |
|
760 | """ | |
776 | toggle the applied flag of the specified item. if no item is specified, |
|
761 | toggle the applied flag of the specified item. if no item is specified, | |
777 | toggle the flag of the currently selected item. |
|
762 | toggle the flag of the currently selected item. | |
778 |
|
||||
779 | """ |
|
763 | """ | |
780 | if item is None: |
|
764 | if item is None: | |
781 | item = self.currentselecteditem |
|
765 | item = self.currentselecteditem | |
@@ -898,7 +882,6 b' class curseschunkselector(object):' | |||||
898 | the screen in the x direction. the current cursor position is |
|
882 | the screen in the x direction. the current cursor position is | |
899 | taken into account when making this calculation. the string can span |
|
883 | taken into account when making this calculation. the string can span | |
900 | multiple lines. |
|
884 | multiple lines. | |
901 |
|
||||
902 | """ |
|
885 | """ | |
903 | y, xstart = window.getyx() |
|
886 | y, xstart = window.getyx() | |
904 | width = self.xscreensize |
|
887 | width = self.xscreensize | |
@@ -927,7 +910,6 b' class curseschunkselector(object):' | |||||
927 | the string stretches to the right border of the window. |
|
910 | the string stretches to the right border of the window. | |
928 |
|
911 | |||
929 | if showwhtspc == True, trailing whitespace of a string is highlighted. |
|
912 | if showwhtspc == True, trailing whitespace of a string is highlighted. | |
930 |
|
||||
931 | """ |
|
913 | """ | |
932 | # preprocess the text, converting tabs to spaces |
|
914 | # preprocess the text, converting tabs to spaces | |
933 | text = text.expandtabs(4) |
|
915 | text = text.expandtabs(4) | |
@@ -1042,8 +1024,8 b' class curseschunkselector(object):' | |||||
1042 | """ |
|
1024 | """ | |
1043 | create a string to prefix a line with which indicates whether 'item' |
|
1025 | create a string to prefix a line with which indicates whether 'item' | |
1044 | is applied and/or folded. |
|
1026 | is applied and/or folded. | |
|
1027 | """ | |||
1045 |
|
1028 | |||
1046 | """ |
|
|||
1047 | # create checkbox string |
|
1029 | # create checkbox string | |
1048 | if item.applied: |
|
1030 | if item.applied: | |
1049 | if not isinstance(item, uihunkline) and item.partial: |
|
1031 | if not isinstance(item, uihunkline) and item.partial: | |
@@ -1076,8 +1058,8 b' class curseschunkselector(object):' | |||||
1076 | """ |
|
1058 | """ | |
1077 | print the header to the pad. if countlines is True, don't print |
|
1059 | print the header to the pad. if countlines is True, don't print | |
1078 | anything, but just count the number of lines which would be printed. |
|
1060 | anything, but just count the number of lines which would be printed. | |
|
1061 | """ | |||
1079 |
|
1062 | |||
1080 | """ |
|
|||
1081 | outstr = "" |
|
1063 | outstr = "" | |
1082 | text = header.prettystr() |
|
1064 | text = header.prettystr() | |
1083 | chunkindex = self.chunklist.index(header) |
|
1065 | chunkindex = self.chunklist.index(header) | |
@@ -1192,6 +1174,7 b' class curseschunkselector(object):' | |||||
1192 | if item is not specified, then print the entire patch. |
|
1174 | if item is not specified, then print the entire patch. | |
1193 | (hiding folded elements, etc. -- see __printitem() docstring) |
|
1175 | (hiding folded elements, etc. -- see __printitem() docstring) | |
1194 | """ |
|
1176 | """ | |
|
1177 | ||||
1195 | if item is None: |
|
1178 | if item is None: | |
1196 | item = self.headerlist |
|
1179 | item = self.headerlist | |
1197 | if recursechildren: |
|
1180 | if recursechildren: | |
@@ -1233,8 +1216,8 b' class curseschunkselector(object):' | |||||
1233 |
|
1216 | |||
1234 | if recursechildren is False, then only print the item without its |
|
1217 | if recursechildren is False, then only print the item without its | |
1235 | child items. |
|
1218 | child items. | |
|
1219 | """ | |||
1236 |
|
1220 | |||
1237 | """ |
|
|||
1238 | if towin and self.outofdisplayedarea(): |
|
1221 | if towin and self.outofdisplayedarea(): | |
1239 | return |
|
1222 | return | |
1240 |
|
1223 | |||
@@ -1281,8 +1264,8 b' class curseschunkselector(object):' | |||||
1281 | if no item is given, assume the entire patch. |
|
1264 | if no item is given, assume the entire patch. | |
1282 | if ignorefolding is True, folded items will be unfolded when counting |
|
1265 | if ignorefolding is True, folded items will be unfolded when counting | |
1283 | the number of lines. |
|
1266 | the number of lines. | |
|
1267 | """ | |||
1284 |
|
1268 | |||
1285 | """ |
|
|||
1286 | # temporarily disable printing to windows by printstring |
|
1269 | # temporarily disable printing to windows by printstring | |
1287 | patchdisplaystring = self.printitem(item, ignorefolding, |
|
1270 | patchdisplaystring = self.printitem(item, ignorefolding, | |
1288 | recursechildren, towin=False) |
|
1271 | recursechildren, towin=False) | |
@@ -1316,8 +1299,8 b' class curseschunkselector(object):' | |||||
1316 | attrlist is used to 'flavor' the returned color-pair. this information |
|
1299 | attrlist is used to 'flavor' the returned color-pair. this information | |
1317 | is not stored in self.colorpairs. it contains attribute values like |
|
1300 | is not stored in self.colorpairs. it contains attribute values like | |
1318 | curses.A_BOLD. |
|
1301 | curses.A_BOLD. | |
|
1302 | """ | |||
1319 |
|
1303 | |||
1320 | """ |
|
|||
1321 | if (name is not None) and name in self.colorpairnames: |
|
1304 | if (name is not None) and name in self.colorpairnames: | |
1322 | # then get the associated color pair and return it |
|
1305 | # then get the associated color pair and return it | |
1323 | colorpair = self.colorpairnames[name] |
|
1306 | colorpair = self.colorpairnames[name] | |
@@ -1448,8 +1431,8 b' are you sure you want to review/edit and' | |||||
1448 | When the amend flag is set, a commit will modify the most recently |
|
1431 | When the amend flag is set, a commit will modify the most recently | |
1449 | committed changeset, instead of creating a new changeset. Otherwise, a |
|
1432 | committed changeset, instead of creating a new changeset. Otherwise, a | |
1450 | new changeset will be created (the normal commit behavior). |
|
1433 | new changeset will be created (the normal commit behavior). | |
|
1434 | """ | |||
1451 |
|
1435 | |||
1452 | """ |
|
|||
1453 | try: |
|
1436 | try: | |
1454 | ver = float(util.version()[:3]) |
|
1437 | ver = float(util.version()[:3]) | |
1455 | except ValueError: |
|
1438 | except ValueError: | |
@@ -1641,8 +1624,8 b' are you sure you want to review/edit and' | |||||
1641 | def main(self, stdscr): |
|
1624 | def main(self, stdscr): | |
1642 | """ |
|
1625 | """ | |
1643 | method to be wrapped by curses.wrapper() for selecting chunks. |
|
1626 | method to be wrapped by curses.wrapper() for selecting chunks. | |
|
1627 | """ | |||
1644 |
|
1628 | |||
1645 | """ |
|
|||
1646 | signal.signal(signal.SIGWINCH, self.sigwinchhandler) |
|
1629 | signal.signal(signal.SIGWINCH, self.sigwinchhandler) | |
1647 | self.stdscr = stdscr |
|
1630 | self.stdscr = stdscr | |
1648 | # error during initialization, cannot be printed in the curses |
|
1631 | # error during initialization, cannot be printed in the curses |
General Comments 0
You need to be logged in to leave comments.
Login now