Show More
@@ -39,7 +39,6 b' from . import (' | |||||
39 | hg, |
|
39 | hg, | |
40 | lock as lockmod, |
|
40 | lock as lockmod, | |
41 | merge as mergemod, |
|
41 | merge as mergemod, | |
42 | minirst, |
|
|||
43 | obsolete, |
|
42 | obsolete, | |
44 | patch, |
|
43 | patch, | |
45 | phases, |
|
44 | phases, | |
@@ -2721,10 +2720,6 b' def help_(ui, name=None, **opts):' | |||||
2721 |
|
2720 | |||
2722 | Returns 0 if successful. |
|
2721 | Returns 0 if successful. | |
2723 | """ |
|
2722 | """ | |
2724 | textwidth = ui.configint('ui', 'textwidth', 78) |
|
|||
2725 | termwidth = ui.termwidth() - 2 |
|
|||
2726 | if textwidth <= 0 or termwidth < textwidth: |
|
|||
2727 | textwidth = termwidth |
|
|||
2728 |
|
2723 | |||
2729 | keep = opts.get('system') or [] |
|
2724 | keep = opts.get('system') or [] | |
2730 | if len(keep) == 0: |
|
2725 | if len(keep) == 0: | |
@@ -2740,37 +2735,7 b' def help_(ui, name=None, **opts):' | |||||
2740 | if ui.verbose: |
|
2735 | if ui.verbose: | |
2741 | keep.append('verbose') |
|
2736 | keep.append('verbose') | |
2742 |
|
2737 | |||
2743 | fullname = name |
|
2738 | formatted = help.formattedhelp(ui, name, keep=keep, **opts) | |
2744 | section = None |
|
|||
2745 | subtopic = None |
|
|||
2746 | if name and '.' in name: |
|
|||
2747 | name, remaining = name.split('.', 1) |
|
|||
2748 | remaining = encoding.lower(remaining) |
|
|||
2749 | if '.' in remaining: |
|
|||
2750 | subtopic, section = remaining.split('.', 1) |
|
|||
2751 | else: |
|
|||
2752 | if name in help.subtopics: |
|
|||
2753 | subtopic = remaining |
|
|||
2754 | else: |
|
|||
2755 | section = remaining |
|
|||
2756 |
|
||||
2757 | text = help.help_(ui, name, subtopic=subtopic, **opts) |
|
|||
2758 |
|
||||
2759 | formatted, pruned = minirst.format(text, textwidth, keep=keep, |
|
|||
2760 | section=section) |
|
|||
2761 |
|
||||
2762 | # We could have been given a weird ".foo" section without a name |
|
|||
2763 | # to look for, or we could have simply failed to found "foo.bar" |
|
|||
2764 | # because bar isn't a section of foo |
|
|||
2765 | if section and not (formatted and name): |
|
|||
2766 | raise error.Abort(_("help section not found: %s") % fullname) |
|
|||
2767 |
|
||||
2768 | if 'verbose' in pruned: |
|
|||
2769 | keep.append('omitted') |
|
|||
2770 | else: |
|
|||
2771 | keep.append('notomitted') |
|
|||
2772 | formatted, pruned = minirst.format(text, textwidth, keep=keep, |
|
|||
2773 | section=section) |
|
|||
2774 | ui.pager('help') |
|
2739 | ui.pager('help') | |
2775 | ui.write(formatted) |
|
2740 | ui.write(formatted) | |
2776 |
|
2741 |
@@ -605,3 +605,47 b' def help_(ui, name, unknowncmd=False, fu' | |||||
605 | rst.extend(helplist(None, **opts)) |
|
605 | rst.extend(helplist(None, **opts)) | |
606 |
|
606 | |||
607 | return ''.join(rst) |
|
607 | return ''.join(rst) | |
|
608 | ||||
|
609 | def formattedhelp(ui, name, keep=None, unknowncmd=False, full=True, **opts): | |||
|
610 | """get help for a given topic (as a dotted name) as rendered rst | |||
|
611 | ||||
|
612 | Either returns the rendered help text or raises an exception. | |||
|
613 | """ | |||
|
614 | if keep is None: | |||
|
615 | keep = [] | |||
|
616 | fullname = name | |||
|
617 | section = None | |||
|
618 | subtopic = None | |||
|
619 | if name and '.' in name: | |||
|
620 | name, remaining = name.split('.', 1) | |||
|
621 | remaining = encoding.lower(remaining) | |||
|
622 | if '.' in remaining: | |||
|
623 | subtopic, section = remaining.split('.', 1) | |||
|
624 | else: | |||
|
625 | if name in subtopics: | |||
|
626 | subtopic = remaining | |||
|
627 | else: | |||
|
628 | section = remaining | |||
|
629 | textwidth = ui.configint('ui', 'textwidth', 78) | |||
|
630 | termwidth = ui.termwidth() - 2 | |||
|
631 | if textwidth <= 0 or termwidth < textwidth: | |||
|
632 | textwidth = termwidth | |||
|
633 | text = help_(ui, name, | |||
|
634 | subtopic=subtopic, unknowncmd=unknowncmd, full=full, **opts) | |||
|
635 | ||||
|
636 | formatted, pruned = minirst.format(text, textwidth, keep=keep, | |||
|
637 | section=section) | |||
|
638 | ||||
|
639 | # We could have been given a weird ".foo" section without a name | |||
|
640 | # to look for, or we could have simply failed to found "foo.bar" | |||
|
641 | # because bar isn't a section of foo | |||
|
642 | if section and not (formatted and name): | |||
|
643 | raise error.Abort(_("help section not found: %s") % fullname) | |||
|
644 | ||||
|
645 | if 'verbose' in pruned: | |||
|
646 | keep.append('omitted') | |||
|
647 | else: | |||
|
648 | keep.append('notomitted') | |||
|
649 | formatted, pruned = minirst.format(text, textwidth, keep=keep, | |||
|
650 | section=section) | |||
|
651 | return formatted |
General Comments 0
You need to be logged in to leave comments.
Login now