Mercurial > hg
annotate mercurial/help.py @ 52095:3e7b9357bbb8
tests: add coverage to for `HGCB_BUNDLE_BASENAME` with special characters
Per request on IRC, to show the behavior of dropping the quoting of
`HGCB_BUNDLE_BASENAME` in the next commit. This current failure is basically
the same error and output that currently happens on Windows with any path (even
without the embedded quote). The only difference is Windows doesn't print the
`cp: cannot stat ...` line.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Mon, 21 Oct 2024 15:24:55 -0400 |
parents | f4733654f144 |
children |
rev | line source |
---|---|
3795
17a11f4ff260
Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1 # help.py - help data for mercurial |
17a11f4ff260
Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
2 # |
46819
d4ba4d51f85f
contributor: change mentions of mpm to olivia
Raphaël Gomès <rgomes@octobus.net>
parents:
46386
diff
changeset
|
3 # Copyright 2006 Olivia Mackall <olivia@selenic.com> |
3795
17a11f4ff260
Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
4 # |
8225
46293a0c7e9f
updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents:
8159
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
10263 | 6 # GNU General Public License version 2 or any later version. |
3795
17a11f4ff260
Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
7 |
51863
f4733654f144
typing: add `from __future__ import annotations` to most files
Matt Harbison <matt_harbison@yahoo.com>
parents:
51862
diff
changeset
|
8 from __future__ import annotations |
27479
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
9 |
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
10 import itertools |
40421
e928bedf0919
help: describe what ui.tweakdefaults changes, concretely
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
40295
diff
changeset
|
11 import re |
27479
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
12 import textwrap |
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
13 |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
14 from typing import ( |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
15 Callable, |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
16 Dict, |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
17 Iterable, |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
18 List, |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
19 Optional, |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
20 Set, |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
21 Tuple, |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
22 Union, |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
23 cast, |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
24 ) |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
25 |
27479
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
26 from .i18n import ( |
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
27 _, |
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
28 gettext, |
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
29 ) |
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
30 from . import ( |
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
31 cmdutil, |
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
32 encoding, |
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
33 error, |
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
34 extensions, |
37091
979c8ce9022d
fancyopts: fix rendering of customopt defaults in help text
Daniel Ploch <dploch@google.com>
parents:
36922
diff
changeset
|
35 fancyopts, |
27479
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
36 filemerge, |
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
37 fileset, |
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
38 minirst, |
32143
964c6be36590
py3: make sure opts are passed and used correctly in help command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32076
diff
changeset
|
39 pycompat, |
40291
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
40 registrar, |
27479
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
41 revset, |
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
42 templatefilters, |
36922
521f6c7e1756
templater: split template functions to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36451
diff
changeset
|
43 templatefuncs, |
27479
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
44 templatekw, |
40421
e928bedf0919
help: describe what ui.tweakdefaults changes, concretely
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
40295
diff
changeset
|
45 ui as uimod, |
27479
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
46 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
47 from .hgweb import webcommands |
43674
5be909dbe385
util: remove datapath and swith users over to resourceutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
43632
diff
changeset
|
48 from .utils import ( |
5be909dbe385
util: remove datapath and swith users over to resourceutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
43632
diff
changeset
|
49 compression, |
5be909dbe385
util: remove datapath and swith users over to resourceutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
43632
diff
changeset
|
50 resourceutil, |
49024
7bd5f862b249
help: use new function for getting first line of string
Martin von Zweigbergk <martinvonz@google.com>
parents:
48923
diff
changeset
|
51 stringutil, |
43674
5be909dbe385
util: remove datapath and swith users over to resourceutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
43632
diff
changeset
|
52 ) |
8863
7b19c3c0172b
help: adding a new help topic about extensions
Cédric Duval <cedricduval@free.fr>
parents:
8668
diff
changeset
|
53 |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
54 _DocLoader = Callable[[uimod.ui], bytes] |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
55 # Old extensions may not register with a category |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
56 _HelpEntry = Union["_HelpEntryNoCategory", "_HelpEntryWithCategory"] |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
57 _HelpEntryNoCategory = Tuple[List[bytes], bytes, _DocLoader] |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
58 _HelpEntryWithCategory = Tuple[List[bytes], bytes, _DocLoader, bytes] |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
59 _SelectFn = Callable[[object], bool] |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
60 _SynonymTable = Dict[bytes, List[bytes]] |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
61 _TopicHook = Callable[[uimod.ui, bytes, bytes], bytes] |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
62 |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
63 _exclkeywords: Set[bytes] = { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
64 b"(ADVANCED)", |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
65 b"(DEPRECATED)", |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
66 b"(EXPERIMENTAL)", |
31080
6918c9215201
help: hide command line options marked as "advanced"
Jun Wu <quark@fb.com>
parents:
31061
diff
changeset
|
67 # i18n: "(ADVANCED)" is a keyword, must be translated consistently |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
68 _(b"(ADVANCED)"), |
26370
44cc9f63a2f1
help: include parens in DEPRECATED/EXPERIMENTAL keywords
Yuya Nishihara <yuya@tcha.org>
parents:
26369
diff
changeset
|
69 # i18n: "(DEPRECATED)" is a keyword, must be translated consistently |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
70 _(b"(DEPRECATED)"), |
26370
44cc9f63a2f1
help: include parens in DEPRECATED/EXPERIMENTAL keywords
Yuya Nishihara <yuya@tcha.org>
parents:
26369
diff
changeset
|
71 # i18n: "(EXPERIMENTAL)" is a keyword, must be translated consistently |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
72 _(b"(EXPERIMENTAL)"), |
32291
bd872f64a8ba
cleanup: use set literals
Martin von Zweigbergk <martinvonz@google.com>
parents:
32143
diff
changeset
|
73 } |
26369
4799b5c4aaf4
help: define list of keywords that should be excluded from non-verbose output
Yuya Nishihara <yuya@tcha.org>
parents:
26238
diff
changeset
|
74 |
40291
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
75 # The order in which command categories will be displayed. |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
76 # Extensions with custom categories should insert them into this list |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
77 # after/before the appropriate item, rather than replacing the list or |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
78 # assuming absolute positions. |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
79 CATEGORY_ORDER: List[bytes] = [ |
40293
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
40292
diff
changeset
|
80 registrar.command.CATEGORY_REPO_CREATION, |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
40292
diff
changeset
|
81 registrar.command.CATEGORY_REMOTE_REPO_MANAGEMENT, |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
40292
diff
changeset
|
82 registrar.command.CATEGORY_COMMITTING, |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
40292
diff
changeset
|
83 registrar.command.CATEGORY_CHANGE_MANAGEMENT, |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
40292
diff
changeset
|
84 registrar.command.CATEGORY_CHANGE_ORGANIZATION, |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
40292
diff
changeset
|
85 registrar.command.CATEGORY_FILE_CONTENTS, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
86 registrar.command.CATEGORY_CHANGE_NAVIGATION, |
40293
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
40292
diff
changeset
|
87 registrar.command.CATEGORY_WORKING_DIRECTORY, |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
40292
diff
changeset
|
88 registrar.command.CATEGORY_IMPORT_EXPORT, |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
40292
diff
changeset
|
89 registrar.command.CATEGORY_MAINTENANCE, |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
40292
diff
changeset
|
90 registrar.command.CATEGORY_HELP, |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
40292
diff
changeset
|
91 registrar.command.CATEGORY_MISC, |
40291
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
92 registrar.command.CATEGORY_NONE, |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
93 ] |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
94 |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
95 # Human-readable category names. These are translated. |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
96 # Extensions with custom categories should add their names here. |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
97 CATEGORY_NAMES: Dict[bytes, bytes] = { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
98 registrar.command.CATEGORY_REPO_CREATION: b'Repository creation', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
99 registrar.command.CATEGORY_REMOTE_REPO_MANAGEMENT: b'Remote repository management', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
100 registrar.command.CATEGORY_COMMITTING: b'Change creation', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
101 registrar.command.CATEGORY_CHANGE_NAVIGATION: b'Change navigation', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
102 registrar.command.CATEGORY_CHANGE_MANAGEMENT: b'Change manipulation', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
103 registrar.command.CATEGORY_CHANGE_ORGANIZATION: b'Change organization', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
104 registrar.command.CATEGORY_WORKING_DIRECTORY: b'Working directory management', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
105 registrar.command.CATEGORY_FILE_CONTENTS: b'File content management', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
106 registrar.command.CATEGORY_IMPORT_EXPORT: b'Change import/export', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
107 registrar.command.CATEGORY_MAINTENANCE: b'Repository maintenance', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
108 registrar.command.CATEGORY_HELP: b'Help', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
109 registrar.command.CATEGORY_MISC: b'Miscellaneous commands', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
110 registrar.command.CATEGORY_NONE: b'Uncategorized commands', |
40291
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
111 } |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
112 |
40292
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
113 # Topic categories. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
114 TOPIC_CATEGORY_IDS = b'ids' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
115 TOPIC_CATEGORY_OUTPUT = b'output' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
116 TOPIC_CATEGORY_CONFIG = b'config' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
117 TOPIC_CATEGORY_CONCEPTS = b'concepts' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
118 TOPIC_CATEGORY_MISC = b'misc' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
119 TOPIC_CATEGORY_NONE = b'none' |
40292
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
120 |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
121 # The order in which topic categories will be displayed. |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
122 # Extensions with custom categories should insert them into this list |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
123 # after/before the appropriate item, rather than replacing the list or |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
124 # assuming absolute positions. |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
125 TOPIC_CATEGORY_ORDER: List[bytes] = [ |
40294
fabbf9310025
help: assigning topic categories
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
126 TOPIC_CATEGORY_IDS, |
fabbf9310025
help: assigning topic categories
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
127 TOPIC_CATEGORY_OUTPUT, |
fabbf9310025
help: assigning topic categories
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
128 TOPIC_CATEGORY_CONFIG, |
fabbf9310025
help: assigning topic categories
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
129 TOPIC_CATEGORY_CONCEPTS, |
fabbf9310025
help: assigning topic categories
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
130 TOPIC_CATEGORY_MISC, |
40292
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
131 TOPIC_CATEGORY_NONE, |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
132 ] |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
133 |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
134 # Human-readable topic category names. These are translated. |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
135 TOPIC_CATEGORY_NAMES: Dict[bytes, bytes] = { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
136 TOPIC_CATEGORY_IDS: b'Mercurial identifiers', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
137 TOPIC_CATEGORY_OUTPUT: b'Mercurial output', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
138 TOPIC_CATEGORY_CONFIG: b'Mercurial configuration', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
139 TOPIC_CATEGORY_CONCEPTS: b'Concepts', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
140 TOPIC_CATEGORY_MISC: b'Miscellaneous', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
141 TOPIC_CATEGORY_NONE: b'Uncategorized topics', |
40292
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
142 } |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
143 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
144 |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
145 def listexts( |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
146 header: bytes, |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
147 exts: Dict[bytes, bytes], |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
148 indent: int = 1, |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
149 showdeprecated: bool = False, |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
150 ) -> List[bytes]: |
8879
d0a3eadfbdb3
help: more improvements for the extensions topic
Cédric Duval <cedricduval@free.fr>
parents:
8871
diff
changeset
|
151 '''return a text listing of the given extensions''' |
16852
af69b2b64d6e
help: format extension lists using RST
Olav Reinert <seroton10@gmail.com>
parents:
16845
diff
changeset
|
152 rst = [] |
af69b2b64d6e
help: format extension lists using RST
Olav Reinert <seroton10@gmail.com>
parents:
16845
diff
changeset
|
153 if exts: |
48913
f254fc73d956
global: bulk replace simple pycompat.iteritems(x) with x.items()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48875
diff
changeset
|
154 for name, desc in sorted(exts.items()): |
26371
51b309ce6c7d
help: unify handling of DEPRECATED/EXPERIMENTAL keywords
Yuya Nishihara <yuya@tcha.org>
parents:
26370
diff
changeset
|
155 if not showdeprecated and any(w in desc for w in _exclkeywords): |
20582
02c303f64917
help: exclude deprecated extensions in the disabled part of 'help extensions'
Augie Fackler <raf@durin42.com>
parents:
20034
diff
changeset
|
156 continue |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
157 rst.append(b'%s:%s: %s\n' % (b' ' * indent, name, desc)) |
27151
7625f6387fc4
help: make listexts less confusing for deprecated exts
timeless <timeless@mozdev.org>
parents:
26845
diff
changeset
|
158 if rst: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
159 rst.insert(0, b'\n%s\n\n' % header) |
16852
af69b2b64d6e
help: format extension lists using RST
Olav Reinert <seroton10@gmail.com>
parents:
16845
diff
changeset
|
160 return rst |
8864
cad6370a15cb
help: refactor extensions listing, and show enabled ones in the dedicated topic
Cédric Duval <cedricduval@free.fr>
parents:
8863
diff
changeset
|
161 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
162 |
51844
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
163 def ext_help(ui: uimod.ui, ext) -> bytes: |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
164 doc = pycompat.getdoc(ext) |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
165 if doc is None: |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
166 return b"" |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
167 assert doc is not None |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
168 doc = gettext(doc) |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
169 return sub_config_item_help(ui, doc) |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
170 |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
171 |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
172 def extshelp(ui: uimod.ui) -> bytes: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
173 rst = loaddoc(b'extensions')(ui).splitlines(True) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
174 rst.extend( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
175 listexts( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
176 _(b'enabled extensions:'), extensions.enabled(), showdeprecated=True |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
177 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
178 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
179 rst.extend( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
180 listexts( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
181 _(b'disabled extensions:'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
182 extensions.disabled(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
183 showdeprecated=ui.verbose, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
184 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
185 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
186 doc = b''.join(rst) |
8863
7b19c3c0172b
help: adding a new help topic about extensions
Cédric Duval <cedricduval@free.fr>
parents:
8668
diff
changeset
|
187 return doc |
7013
f56e788fa292
i18n: mark help strings for translation
Martin Geisler <mg@daimi.au.dk>
parents:
7012
diff
changeset
|
188 |
44306
a0ec05d93c8e
cleanup: re-run black on the codebase
Augie Fackler <augie@google.com>
parents:
44295
diff
changeset
|
189 |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
190 def parsedefaultmarker(text: bytes) -> Optional[Tuple[bytes, List[bytes]]]: |
44295
142d2a4cb69a
help: add a mechanism to change flags' help depending on config
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44027
diff
changeset
|
191 """given a text 'abc (DEFAULT: def.ghi)', |
142d2a4cb69a
help: add a mechanism to change flags' help depending on config
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44027
diff
changeset
|
192 returns (b'abc', (b'def', b'ghi')). Otherwise return None""" |
142d2a4cb69a
help: add a mechanism to change flags' help depending on config
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44027
diff
changeset
|
193 if text[-1:] == b')': |
142d2a4cb69a
help: add a mechanism to change flags' help depending on config
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44027
diff
changeset
|
194 marker = b' (DEFAULT: ' |
142d2a4cb69a
help: add a mechanism to change flags' help depending on config
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44027
diff
changeset
|
195 pos = text.find(marker) |
142d2a4cb69a
help: add a mechanism to change flags' help depending on config
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44027
diff
changeset
|
196 if pos >= 0: |
44306
a0ec05d93c8e
cleanup: re-run black on the codebase
Augie Fackler <augie@google.com>
parents:
44295
diff
changeset
|
197 item = text[pos + len(marker) : -1] |
44295
142d2a4cb69a
help: add a mechanism to change flags' help depending on config
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44027
diff
changeset
|
198 return text[:pos], item.split(b'.', 2) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
199 |
44306
a0ec05d93c8e
cleanup: re-run black on the codebase
Augie Fackler <augie@google.com>
parents:
44295
diff
changeset
|
200 |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
201 def optrst(header: bytes, options, verbose: bool, ui: uimod.ui) -> bytes: |
16781
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
202 data = [] |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
203 multioccur = False |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
204 for option in options: |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
205 if len(option) == 5: |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
206 shortopt, longopt, default, desc, optlabel = option |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
207 else: |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
208 shortopt, longopt, default, desc = option |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
209 optlabel = _(b"VALUE") # default label |
16781
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
210 |
26369
4799b5c4aaf4
help: define list of keywords that should be excluded from non-verbose output
Yuya Nishihara <yuya@tcha.org>
parents:
26238
diff
changeset
|
211 if not verbose and any(w in desc for w in _exclkeywords): |
16781
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
212 continue |
44295
142d2a4cb69a
help: add a mechanism to change flags' help depending on config
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44027
diff
changeset
|
213 defaultstrsuffix = b'' |
142d2a4cb69a
help: add a mechanism to change flags' help depending on config
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44027
diff
changeset
|
214 if default is None: |
142d2a4cb69a
help: add a mechanism to change flags' help depending on config
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44027
diff
changeset
|
215 parseresult = parsedefaultmarker(desc) |
142d2a4cb69a
help: add a mechanism to change flags' help depending on config
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44027
diff
changeset
|
216 if parseresult is not None: |
142d2a4cb69a
help: add a mechanism to change flags' help depending on config
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44027
diff
changeset
|
217 (desc, (section, name)) = parseresult |
142d2a4cb69a
help: add a mechanism to change flags' help depending on config
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44027
diff
changeset
|
218 if ui.configbool(section, name): |
142d2a4cb69a
help: add a mechanism to change flags' help depending on config
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44027
diff
changeset
|
219 default = True |
142d2a4cb69a
help: add a mechanism to change flags' help depending on config
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44027
diff
changeset
|
220 defaultstrsuffix = _(b' from config') |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
221 so = b'' |
16781
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
222 if shortopt: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
223 so = b'-' + shortopt |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
224 lo = b'--' + longopt |
41009
fcc0a7ac9ebd
help: show "[no-]" only for default-on Flags
Martin von Zweigbergk <martinvonz@google.com>
parents:
40955
diff
changeset
|
225 if default is True: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
226 lo = b'--[no-]' + longopt |
37091
979c8ce9022d
fancyopts: fix rendering of customopt defaults in help text
Daniel Ploch <dploch@google.com>
parents:
36922
diff
changeset
|
227 |
979c8ce9022d
fancyopts: fix rendering of customopt defaults in help text
Daniel Ploch <dploch@google.com>
parents:
36922
diff
changeset
|
228 if isinstance(default, fancyopts.customopt): |
37092
ef6215df2402
fancyopts: prevent mutation of the default value in customopts
Daniel Ploch <dploch@google.com>
parents:
37091
diff
changeset
|
229 default = default.getdefaultvalue() |
41010
e8e2a7656e83
help: hide default value for default-off flags
Martin von Zweigbergk <martinvonz@google.com>
parents:
41009
diff
changeset
|
230 if default and not callable(default): |
32619
d110fb58424c
help: convert flag default to bytes portably
Augie Fackler <raf@durin42.com>
parents:
32615
diff
changeset
|
231 # default is of unknown type, and in Python 2 we abused |
d110fb58424c
help: convert flag default to bytes portably
Augie Fackler <raf@durin42.com>
parents:
32615
diff
changeset
|
232 # the %s-shows-repr property to handle integers etc. To |
d110fb58424c
help: convert flag default to bytes portably
Augie Fackler <raf@durin42.com>
parents:
32615
diff
changeset
|
233 # match that behavior on Python 3, we do str(default) and |
d110fb58424c
help: convert flag default to bytes portably
Augie Fackler <raf@durin42.com>
parents:
32615
diff
changeset
|
234 # then convert it to bytes. |
40953
05abb5fb146a
help: use "default: on" instead of "default: True"
Martin von Zweigbergk <martinvonz@google.com>
parents:
40595
diff
changeset
|
235 defaultstr = pycompat.bytestr(default) |
41010
e8e2a7656e83
help: hide default value for default-off flags
Martin von Zweigbergk <martinvonz@google.com>
parents:
41009
diff
changeset
|
236 if default is True: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
237 defaultstr = _(b"on") |
44295
142d2a4cb69a
help: add a mechanism to change flags' help depending on config
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44027
diff
changeset
|
238 desc += _(b" (default: %s)") % (defaultstr + defaultstrsuffix) |
16781
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
239 |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
240 if isinstance(default, list): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
241 lo += b" %s [+]" % optlabel |
16781
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
242 multioccur = True |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
243 elif (default is not None) and not isinstance(default, bool): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
244 lo += b" %s" % optlabel |
16781
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
245 |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
246 data.append((so, lo, desc)) |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
247 |
22117
c1d93edcf004
help: fold repeatable option message into option table header
Matt Mackall <mpm@selenic.com>
parents:
22116
diff
changeset
|
248 if multioccur: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
249 header += _(b" ([+] can be repeated)") |
16781
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
250 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
251 rst = [b'\n%s:\n\n' % header] |
22116
161085f87b95
help: roll option list header into option formatter
Matt Mackall <mpm@selenic.com>
parents:
22115
diff
changeset
|
252 rst.extend(minirst.maketable(data, 1)) |
16781
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
253 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
254 return b''.join(rst) |
16781
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
255 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
256 |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
257 def indicateomitted( |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
258 rst: List[bytes], omitted: bytes, notomitted: Optional[bytes] = None |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
259 ) -> None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
260 rst.append(b'\n\n.. container:: omitted\n\n %s\n\n' % omitted) |
17837
b623e323c561
help: indicate help omitting if help document is not fully displayed
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17323
diff
changeset
|
261 if notomitted: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
262 rst.append(b'\n\n.. container:: notomitted\n\n %s\n\n' % notomitted) |
17837
b623e323c561
help: indicate help omitting if help document is not fully displayed
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17323
diff
changeset
|
263 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
264 |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
265 def filtercmd(ui: uimod.ui, cmd: bytes, func, kw: bytes, doc: bytes) -> bool: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
266 if not ui.debugflag and cmd.startswith(b"debug") and kw != b"debug": |
40414
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40413
diff
changeset
|
267 # Debug command, and user is not looking for those. |
27323 | 268 return True |
40414
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40413
diff
changeset
|
269 if not ui.verbose: |
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40413
diff
changeset
|
270 if not kw and not doc: |
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40413
diff
changeset
|
271 # Command had no documentation, no point in showing it by default. |
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40413
diff
changeset
|
272 return True |
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40413
diff
changeset
|
273 if getattr(func, 'alias', False) and not getattr(func, 'owndoc', False): |
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40413
diff
changeset
|
274 # Alias didn't have its own documentation. |
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40413
diff
changeset
|
275 return True |
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40413
diff
changeset
|
276 if doc and any(w in doc for w in _exclkeywords): |
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40413
diff
changeset
|
277 # Documentation has excluded keywords. |
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40413
diff
changeset
|
278 return True |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
279 if kw == b"shortlist" and not getattr(func, 'helpbasic', False): |
40414
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40413
diff
changeset
|
280 # We're presenting the short list but the command is not basic. |
27323 | 281 return True |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
282 if ui.configbool(b'help', b'hidden-command.%s' % cmd): |
40414
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40413
diff
changeset
|
283 # Configuration explicitly hides the command. |
27323 | 284 return True |
285 return False | |
286 | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
287 |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
288 def filtertopic(ui: uimod.ui, topic: bytes) -> bool: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
289 return ui.configbool(b'help', b'hidden-topic.%s' % topic, False) |
40413 | 290 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
291 |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
292 def topicmatch( |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
293 ui: uimod.ui, commands, kw: bytes |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
294 ) -> Dict[bytes, List[Tuple[bytes, bytes]]]: |
16710
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
295 """Return help topics matching kw. |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
296 |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
297 Returns {'section': [(name, summary), ...], ...} where section is |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
298 one of topics, commands, extensions, or extensioncommands. |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
299 """ |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
300 kw = encoding.lower(kw) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
301 |
16710
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
302 def lowercontains(container): |
16845
4594729c61ee
help: fix search with `-k` option in non-ASCII locales
Nikolaj Sjujskij <sterkrig@myopera.com>
parents:
16816
diff
changeset
|
303 return kw in encoding.lower(container) # translated in helptable |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
304 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
305 results = { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
306 b'topics': [], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
307 b'commands': [], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
308 b'extensions': [], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
309 b'extensioncommands': [], |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
310 } |
40292
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
311 for topic in helptable: |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
312 names, header, doc = topic[0:3] |
22322
e284de138f00
help: only call doc() when it is callable
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21796
diff
changeset
|
313 # Old extensions may use a str as doc. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
314 if ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
315 sum(map(lowercontains, names)) |
16710
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
316 or lowercontains(header) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
317 or (callable(doc) and lowercontains(doc(ui))) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
318 ): |
40413 | 319 name = names[0] |
320 if not filtertopic(ui, name): | |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
321 results[b'topics'].append((names[0], header)) |
48913
f254fc73d956
global: bulk replace simple pycompat.iteritems(x) with x.items()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48875
diff
changeset
|
322 for cmd, entry in commands.table.items(): |
16710
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
323 if len(entry) == 3: |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
324 summary = entry[2] |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
325 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
326 summary = b'' |
16845
4594729c61ee
help: fix search with `-k` option in non-ASCII locales
Nikolaj Sjujskij <sterkrig@myopera.com>
parents:
16816
diff
changeset
|
327 # translate docs *before* searching there |
40414
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40413
diff
changeset
|
328 func = entry[0] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
329 docs = _(pycompat.getdoc(func)) or b'' |
16710
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
330 if kw in cmd or lowercontains(summary) or lowercontains(docs): |
49024
7bd5f862b249
help: use new function for getting first line of string
Martin von Zweigbergk <martinvonz@google.com>
parents:
48923
diff
changeset
|
331 if docs: |
7bd5f862b249
help: use new function for getting first line of string
Martin von Zweigbergk <martinvonz@google.com>
parents:
48923
diff
changeset
|
332 summary = stringutil.firstline(docs) |
36250
4174970c9147
help: use cmdutil.parsealiases() to resolve command name
Yuya Nishihara <yuya@tcha.org>
parents:
36249
diff
changeset
|
333 cmdname = cmdutil.parsealiases(cmd)[0] |
40414
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40413
diff
changeset
|
334 if filtercmd(ui, cmdname, func, kw, docs): |
27324
5456374561a7
help: call filtercmd from topicmatch
timeless <timeless@mozdev.org>
parents:
27323
diff
changeset
|
335 continue |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
336 results[b'commands'].append((cmdname, summary)) |
16710
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
337 for name, docs in itertools.chain( |
48923
428177ad70b0
help: remove pycompat.iteritems()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48913
diff
changeset
|
338 extensions.enabled(False).items(), |
428177ad70b0
help: remove pycompat.iteritems()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48913
diff
changeset
|
339 extensions.disabled().items(), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
340 ): |
28058
ff6e8dc659f8
help: don't crash in keyword search if an extension fails to provide docs
Simon Farnsworth <simonfar@fb.com>
parents:
27660
diff
changeset
|
341 if not docs: |
ff6e8dc659f8
help: don't crash in keyword search if an extension fails to provide docs
Simon Farnsworth <simonfar@fb.com>
parents:
27660
diff
changeset
|
342 continue |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
343 name = name.rpartition(b'.')[-1] |
16710
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
344 if lowercontains(name) or lowercontains(docs): |
16845
4594729c61ee
help: fix search with `-k` option in non-ASCII locales
Nikolaj Sjujskij <sterkrig@myopera.com>
parents:
16816
diff
changeset
|
345 # extension docs are already translated |
49024
7bd5f862b249
help: use new function for getting first line of string
Martin von Zweigbergk <martinvonz@google.com>
parents:
48923
diff
changeset
|
346 results[b'extensions'].append((name, stringutil.firstline(docs))) |
34912
1e2454b60e59
help: do not abort topicmatch() because of unimportable extensions
Yuya Nishihara <yuya@tcha.org>
parents:
33499
diff
changeset
|
347 try: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
348 mod = extensions.load(ui, name, b'') |
34912
1e2454b60e59
help: do not abort topicmatch() because of unimportable extensions
Yuya Nishihara <yuya@tcha.org>
parents:
33499
diff
changeset
|
349 except ImportError: |
1e2454b60e59
help: do not abort topicmatch() because of unimportable extensions
Yuya Nishihara <yuya@tcha.org>
parents:
33499
diff
changeset
|
350 # debug message would be printed in extensions.load() |
1e2454b60e59
help: do not abort topicmatch() because of unimportable extensions
Yuya Nishihara <yuya@tcha.org>
parents:
33499
diff
changeset
|
351 continue |
48923
428177ad70b0
help: remove pycompat.iteritems()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48913
diff
changeset
|
352 for cmd, entry in getattr(mod, 'cmdtable', {}).items(): |
16711
497deec204d1
help: add --keyword (-k) for searching help
Augie Fackler <raf@durin42.com>
parents:
16710
diff
changeset
|
353 if kw in cmd or (len(entry) > 2 and lowercontains(entry[2])): |
36250
4174970c9147
help: use cmdutil.parsealiases() to resolve command name
Yuya Nishihara <yuya@tcha.org>
parents:
36249
diff
changeset
|
354 cmdname = cmdutil.parsealiases(cmd)[0] |
40414
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40413
diff
changeset
|
355 func = entry[0] |
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40413
diff
changeset
|
356 cmddoc = pycompat.getdoc(func) |
32615
c9318beb7c1a
py3: convert __doc__ back to bytes in help.py
Yuya Nishihara <yuya@tcha.org>
parents:
32566
diff
changeset
|
357 if cmddoc: |
49024
7bd5f862b249
help: use new function for getting first line of string
Martin von Zweigbergk <martinvonz@google.com>
parents:
48923
diff
changeset
|
358 cmddoc = stringutil.firstline(gettext(cmddoc)) |
16884
4fd1f1d7569b
help: fix 'hg help -k' matching an extension without docs
Thomas Arendsen Hein <thomas@intevation.de>
parents:
16855
diff
changeset
|
359 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
360 cmddoc = _(b'(no help text available)') |
40414
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40413
diff
changeset
|
361 if filtercmd(ui, cmdname, func, kw, cmddoc): |
27387
dfab0afde928
help: filter extension commands
timeless <timeless@mozdev.org>
parents:
27379
diff
changeset
|
362 continue |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
363 results[b'extensioncommands'].append((cmdname, cmddoc)) |
16710
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
364 return results |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
365 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
366 |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
367 def loaddoc(topic: bytes, subdir: Optional[bytes] = None) -> _DocLoader: |
9539
c904e76e3834
help: move help topics from mercurial/help.py to help/*.txt
Martin Geisler <mg@lazybytes.net>
parents:
9536
diff
changeset
|
368 """Return a delayed loader for help/topic.txt.""" |
3798 | 369 |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
370 def loader(ui: uimod.ui) -> bytes: |
44027
52f0140c2604
resourceutil: don't limit resources to the `mercurial` package
Matt Harbison <matt_harbison@yahoo.com>
parents:
43871
diff
changeset
|
371 package = b'mercurial.helptext' |
27375
c4a062d090ee
help: teach loaddoc to load from a different directory
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27325
diff
changeset
|
372 if subdir: |
44027
52f0140c2604
resourceutil: don't limit resources to the `mercurial` package
Matt Harbison <matt_harbison@yahoo.com>
parents:
43871
diff
changeset
|
373 package += b'.' + subdir |
43871
1390bb81163e
help: get helptext/ data from `resources` module if available
Martin von Zweigbergk <martinvonz@google.com>
parents:
43674
diff
changeset
|
374 with resourceutil.open_resource(package, topic + b'.txt') as fp: |
1390bb81163e
help: get helptext/ data from `resources` module if available
Martin von Zweigbergk <martinvonz@google.com>
parents:
43674
diff
changeset
|
375 doc = gettext(fp.read()) |
12820
0edc0aa7432d
help: add topic rewriting hooks
Patrick Mezard <pmezard@gmail.com>
parents:
12818
diff
changeset
|
376 for rewriter in helphooks.get(topic, []): |
26414
c44b507e7c78
help: pass around ui to rewriter hooks (API)
Yuya Nishihara <yuya@tcha.org>
parents:
26413
diff
changeset
|
377 doc = rewriter(ui, topic, doc) |
51844
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
378 doc = sub_config_item_help(ui, doc) |
12820
0edc0aa7432d
help: add topic rewriting hooks
Patrick Mezard <pmezard@gmail.com>
parents:
12818
diff
changeset
|
379 return doc |
0edc0aa7432d
help: add topic rewriting hooks
Patrick Mezard <pmezard@gmail.com>
parents:
12818
diff
changeset
|
380 |
9539
c904e76e3834
help: move help topics from mercurial/help.py to help/*.txt
Martin Geisler <mg@lazybytes.net>
parents:
9536
diff
changeset
|
381 return loader |
7677
6a0bc2dc9da6
help: add a topic about some of the templating features
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7387
diff
changeset
|
382 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
383 |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
384 internalstable: List[_HelpEntryNoCategory] = sorted( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
385 [ |
45059
79f6f9fa18c1
documentation: add some internals documentation about bid merge
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44657
diff
changeset
|
386 ( |
79f6f9fa18c1
documentation: add some internals documentation about bid merge
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44657
diff
changeset
|
387 [b'bid-merge'], |
79f6f9fa18c1
documentation: add some internals documentation about bid merge
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44657
diff
changeset
|
388 _(b'Bid Merge Algorithm'), |
79f6f9fa18c1
documentation: add some internals documentation about bid merge
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44657
diff
changeset
|
389 loaddoc(b'bid-merge', subdir=b'internals'), |
79f6f9fa18c1
documentation: add some internals documentation about bid merge
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44657
diff
changeset
|
390 ), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
391 ([b'bundle2'], _(b'Bundle2'), loaddoc(b'bundle2', subdir=b'internals')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
392 ([b'bundles'], _(b'Bundles'), loaddoc(b'bundles', subdir=b'internals')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
393 ([b'cbor'], _(b'CBOR'), loaddoc(b'cbor', subdir=b'internals')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
394 ([b'censor'], _(b'Censor'), loaddoc(b'censor', subdir=b'internals')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
395 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
396 [b'changegroups'], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
397 _(b'Changegroups'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
398 loaddoc(b'changegroups', subdir=b'internals'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
399 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
400 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
401 [b'config'], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
402 _(b'Config Registrar'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
403 loaddoc(b'config', subdir=b'internals'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
404 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
405 ( |
48166
e8a576de703f
dirstate-v2: Add internal documentation
Simon Sapin <simon.sapin@octobus.net>
parents:
47017
diff
changeset
|
406 [b'dirstate-v2'], |
e8a576de703f
dirstate-v2: Add internal documentation
Simon Sapin <simon.sapin@octobus.net>
parents:
47017
diff
changeset
|
407 _(b'dirstate-v2 file format'), |
e8a576de703f
dirstate-v2: Add internal documentation
Simon Sapin <simon.sapin@octobus.net>
parents:
47017
diff
changeset
|
408 loaddoc(b'dirstate-v2', subdir=b'internals'), |
e8a576de703f
dirstate-v2: Add internal documentation
Simon Sapin <simon.sapin@octobus.net>
parents:
47017
diff
changeset
|
409 ), |
e8a576de703f
dirstate-v2: Add internal documentation
Simon Sapin <simon.sapin@octobus.net>
parents:
47017
diff
changeset
|
410 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
411 [b'extensions', b'extension'], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
412 _(b'Extension API'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
413 loaddoc(b'extensions', subdir=b'internals'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
414 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
415 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
416 [b'mergestate'], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
417 _(b'Mergestate'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
418 loaddoc(b'mergestate', subdir=b'internals'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
419 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
420 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
421 [b'requirements'], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
422 _(b'Repository Requirements'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
423 loaddoc(b'requirements', subdir=b'internals'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
424 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
425 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
426 [b'revlogs'], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
427 _(b'Revision Logs'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
428 loaddoc(b'revlogs', subdir=b'internals'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
429 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
430 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
431 [b'wireprotocol'], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
432 _(b'Wire Protocol'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
433 loaddoc(b'wireprotocol', subdir=b'internals'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
434 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
435 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
436 [b'wireprotocolrpc'], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
437 _(b'Wire Protocol RPC'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
438 loaddoc(b'wireprotocolrpc', subdir=b'internals'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
439 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
440 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
441 [b'wireprotocolv2'], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
442 _(b'Wire Protocol Version 2'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
443 loaddoc(b'wireprotocolv2', subdir=b'internals'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
444 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
445 ] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
446 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
447 |
27376
fc810d950278
help: add "internals" topic
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27375
diff
changeset
|
448 |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
449 def internalshelp(ui: uimod.ui) -> bytes: |
27376
fc810d950278
help: add "internals" topic
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27375
diff
changeset
|
450 """Generate the index for the "internals" topic.""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
451 lines = [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
452 b'To access a subtopic, use "hg help internals.{subtopic-name}"\n', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
453 b'\n', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
454 ] |
27376
fc810d950278
help: add "internals" topic
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27375
diff
changeset
|
455 for names, header, doc in internalstable: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
456 lines.append(b' :%s: %s\n' % (names[0], header)) |
27376
fc810d950278
help: add "internals" topic
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27375
diff
changeset
|
457 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
458 return b''.join(lines) |
27376
fc810d950278
help: add "internals" topic
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27375
diff
changeset
|
459 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
460 |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
461 helptable: List[_HelpEntryWithCategory] = sorted( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
462 [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
463 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
464 [b'bundlespec'], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
465 _(b"Bundle File Formats"), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
466 loaddoc(b'bundlespec'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
467 TOPIC_CATEGORY_CONCEPTS, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
468 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
469 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
470 [b'color'], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
471 _(b"Colorizing Outputs"), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
472 loaddoc(b'color'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
473 TOPIC_CATEGORY_OUTPUT, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
474 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
475 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
476 [b"config", b"hgrc"], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
477 _(b"Configuration Files"), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
478 loaddoc(b'config'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
479 TOPIC_CATEGORY_CONFIG, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
480 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
481 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
482 [b'deprecated'], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
483 _(b"Deprecated Features"), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
484 loaddoc(b'deprecated'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
485 TOPIC_CATEGORY_MISC, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
486 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
487 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
488 [b"dates"], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
489 _(b"Date Formats"), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
490 loaddoc(b'dates'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
491 TOPIC_CATEGORY_OUTPUT, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
492 ), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
493 ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
494 [b"flags"], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
495 _(b"Command-line flags"), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
496 loaddoc(b'flags'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
497 TOPIC_CATEGORY_CONFIG, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
498 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
499 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
500 [b"patterns"], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
501 _(b"File Name Patterns"), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
502 loaddoc(b'patterns'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
503 TOPIC_CATEGORY_IDS, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
504 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
505 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
506 [b'environment', b'env'], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
507 _(b'Environment Variables'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
508 loaddoc(b'environment'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
509 TOPIC_CATEGORY_CONFIG, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
510 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
511 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
512 [ |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
513 b'revisions', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
514 b'revs', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
515 b'revsets', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
516 b'revset', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
517 b'multirevs', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
518 b'mrevs', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
519 ], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
520 _(b'Specifying Revisions'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
521 loaddoc(b'revisions'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
522 TOPIC_CATEGORY_IDS, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
523 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
524 ( |
48532
7ccd31fda132
docs: add documentation about Rust
Raphaël Gomès <rgomes@octobus.net>
parents:
48166
diff
changeset
|
525 [ |
7ccd31fda132
docs: add documentation about Rust
Raphaël Gomès <rgomes@octobus.net>
parents:
48166
diff
changeset
|
526 b'rust', |
7ccd31fda132
docs: add documentation about Rust
Raphaël Gomès <rgomes@octobus.net>
parents:
48166
diff
changeset
|
527 b'rustext', |
49565
04e6add9e4dc
config: add alias from `hg help rhg` to `hg help rust`
Raphaël Gomès <rgomes@octobus.net>
parents:
49024
diff
changeset
|
528 b'rhg', |
48532
7ccd31fda132
docs: add documentation about Rust
Raphaël Gomès <rgomes@octobus.net>
parents:
48166
diff
changeset
|
529 ], |
7ccd31fda132
docs: add documentation about Rust
Raphaël Gomès <rgomes@octobus.net>
parents:
48166
diff
changeset
|
530 _(b'Rust in Mercurial'), |
7ccd31fda132
docs: add documentation about Rust
Raphaël Gomès <rgomes@octobus.net>
parents:
48166
diff
changeset
|
531 loaddoc(b'rust'), |
7ccd31fda132
docs: add documentation about Rust
Raphaël Gomès <rgomes@octobus.net>
parents:
48166
diff
changeset
|
532 TOPIC_CATEGORY_CONFIG, |
7ccd31fda132
docs: add documentation about Rust
Raphaël Gomès <rgomes@octobus.net>
parents:
48166
diff
changeset
|
533 ), |
7ccd31fda132
docs: add documentation about Rust
Raphaël Gomès <rgomes@octobus.net>
parents:
48166
diff
changeset
|
534 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
535 [b'filesets', b'fileset'], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
536 _(b"Specifying File Sets"), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
537 loaddoc(b'filesets'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
538 TOPIC_CATEGORY_IDS, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
539 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
540 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
541 [b'diffs'], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
542 _(b'Diff Formats'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
543 loaddoc(b'diffs'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
544 TOPIC_CATEGORY_OUTPUT, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
545 ), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
546 ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
547 [b'merge-tools', b'mergetools', b'mergetool'], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
548 _(b'Merge Tools'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
549 loaddoc(b'merge-tools'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
550 TOPIC_CATEGORY_CONFIG, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
551 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
552 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
553 [b'templating', b'templates', b'template', b'style'], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
554 _(b'Template Usage'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
555 loaddoc(b'templates'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
556 TOPIC_CATEGORY_OUTPUT, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
557 ), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
558 ([b'urls'], _(b'URL Paths'), loaddoc(b'urls'), TOPIC_CATEGORY_IDS), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
559 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
560 [b"extensions"], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
561 _(b"Using Additional Features"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
562 extshelp, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
563 TOPIC_CATEGORY_CONFIG, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
564 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
565 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
566 [b"subrepos", b"subrepo"], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
567 _(b"Subrepositories"), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
568 loaddoc(b'subrepos'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
569 TOPIC_CATEGORY_CONCEPTS, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
570 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
571 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
572 [b"hgweb"], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
573 _(b"Configuring hgweb"), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
574 loaddoc(b'hgweb'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
575 TOPIC_CATEGORY_CONFIG, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
576 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
577 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
578 [b"glossary"], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
579 _(b"Glossary"), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
580 loaddoc(b'glossary'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
581 TOPIC_CATEGORY_CONCEPTS, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
582 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
583 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
584 [b"hgignore", b"ignore"], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
585 _(b"Syntax for Mercurial Ignore Files"), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
586 loaddoc(b'hgignore'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
587 TOPIC_CATEGORY_IDS, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
588 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
589 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
590 [b"phases"], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
591 _(b"Working with Phases"), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
592 loaddoc(b'phases'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
593 TOPIC_CATEGORY_CONCEPTS, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
594 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
595 ( |
47017
da4e6d7a8fdd
help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
46819
diff
changeset
|
596 [b"evolution"], |
da4e6d7a8fdd
help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
46819
diff
changeset
|
597 _(b"Safely rewriting history (EXPERIMENTAL)"), |
da4e6d7a8fdd
help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
46819
diff
changeset
|
598 loaddoc(b'evolution'), |
da4e6d7a8fdd
help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
46819
diff
changeset
|
599 TOPIC_CATEGORY_CONCEPTS, |
da4e6d7a8fdd
help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
46819
diff
changeset
|
600 ), |
da4e6d7a8fdd
help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
46819
diff
changeset
|
601 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
602 [b'scripting'], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
603 _(b'Using Mercurial from scripts and automation'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
604 loaddoc(b'scripting'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
605 TOPIC_CATEGORY_MISC, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
606 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
607 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
608 [b'internals'], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
609 _(b"Technical implementation topics"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
610 internalshelp, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
611 TOPIC_CATEGORY_MISC, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
612 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
613 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
614 [b'pager'], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
615 _(b"Pager Support"), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
616 loaddoc(b'pager'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
617 TOPIC_CATEGORY_CONFIG, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
618 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
619 ] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
620 ) |
12820
0edc0aa7432d
help: add topic rewriting hooks
Patrick Mezard <pmezard@gmail.com>
parents:
12818
diff
changeset
|
621 |
27379
2278870bb997
help: support loading sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27378
diff
changeset
|
622 # Maps topics with sub-topics to a list of their sub-topics. |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
623 subtopics: Dict[bytes, List[_HelpEntryNoCategory]] = { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
624 b'internals': internalstable, |
27379
2278870bb997
help: support loading sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27378
diff
changeset
|
625 } |
2278870bb997
help: support loading sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27378
diff
changeset
|
626 |
12820
0edc0aa7432d
help: add topic rewriting hooks
Patrick Mezard <pmezard@gmail.com>
parents:
12818
diff
changeset
|
627 # Map topics to lists of callable taking the current topic help and |
0edc0aa7432d
help: add topic rewriting hooks
Patrick Mezard <pmezard@gmail.com>
parents:
12818
diff
changeset
|
628 # returning the updated version |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
629 helphooks: Dict[bytes, List[_TopicHook]] = {} |
12820
0edc0aa7432d
help: add topic rewriting hooks
Patrick Mezard <pmezard@gmail.com>
parents:
12818
diff
changeset
|
630 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
631 |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
632 def addtopichook(topic: bytes, rewriter: _TopicHook) -> None: |
12820
0edc0aa7432d
help: add topic rewriting hooks
Patrick Mezard <pmezard@gmail.com>
parents:
12818
diff
changeset
|
633 helphooks.setdefault(topic, []).append(rewriter) |
13593
cc4721ed7a2a
help: extract items doc generation function
Patrick Mezard <pmezard@gmail.com>
parents:
12828
diff
changeset
|
634 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
635 |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
636 def makeitemsdoc( |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
637 ui: uimod.ui, |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
638 topic: bytes, |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
639 doc: bytes, |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
640 marker: bytes, |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
641 items: Dict[bytes, bytes], |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
642 dedent: bool = False, |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
643 ) -> bytes: |
13593
cc4721ed7a2a
help: extract items doc generation function
Patrick Mezard <pmezard@gmail.com>
parents:
12828
diff
changeset
|
644 """Extract docstring from the items key to function mapping, build a |
26196
3a4620ad4490
help: fix makeitemsdoc English description
timeless@mozdev.org
parents:
25881
diff
changeset
|
645 single documentation block and use it to overwrite the marker in doc. |
13593
cc4721ed7a2a
help: extract items doc generation function
Patrick Mezard <pmezard@gmail.com>
parents:
12828
diff
changeset
|
646 """ |
cc4721ed7a2a
help: extract items doc generation function
Patrick Mezard <pmezard@gmail.com>
parents:
12828
diff
changeset
|
647 entries = [] |
cc4721ed7a2a
help: extract items doc generation function
Patrick Mezard <pmezard@gmail.com>
parents:
12828
diff
changeset
|
648 for name in sorted(items): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
649 text = (pycompat.getdoc(items[name]) or b'').rstrip() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
650 if not text or not ui.verbose and any(w in text for w in _exclkeywords): |
13593
cc4721ed7a2a
help: extract items doc generation function
Patrick Mezard <pmezard@gmail.com>
parents:
12828
diff
changeset
|
651 continue |
cc4721ed7a2a
help: extract items doc generation function
Patrick Mezard <pmezard@gmail.com>
parents:
12828
diff
changeset
|
652 text = gettext(text) |
24098
067540702f64
help: teach topic symbols how to dedent
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24080
diff
changeset
|
653 if dedent: |
32549
633c635a790a
help: work around textwrap.dedent() only working on strings
Augie Fackler <raf@durin42.com>
parents:
32547
diff
changeset
|
654 # Abuse latin1 to use textwrap.dedent() on bytes. |
633c635a790a
help: work around textwrap.dedent() only working on strings
Augie Fackler <raf@durin42.com>
parents:
32547
diff
changeset
|
655 text = textwrap.dedent(text.decode('latin1')).encode('latin1') |
13593
cc4721ed7a2a
help: extract items doc generation function
Patrick Mezard <pmezard@gmail.com>
parents:
12828
diff
changeset
|
656 lines = text.splitlines() |
49024
7bd5f862b249
help: use new function for getting first line of string
Martin von Zweigbergk <martinvonz@google.com>
parents:
48923
diff
changeset
|
657 doclines = [lines[0]] |
16250
684864d54903
help: strip doctest from dochelp
"Yann E. MORIN" <yann.morin.1998@free.fr>
parents:
16126
diff
changeset
|
658 for l in lines[1:]: |
684864d54903
help: strip doctest from dochelp
"Yann E. MORIN" <yann.morin.1998@free.fr>
parents:
16126
diff
changeset
|
659 # Stop once we find some Python doctest |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
660 if l.strip().startswith(b'>>>'): |
16250
684864d54903
help: strip doctest from dochelp
"Yann E. MORIN" <yann.morin.1998@free.fr>
parents:
16126
diff
changeset
|
661 break |
24098
067540702f64
help: teach topic symbols how to dedent
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24080
diff
changeset
|
662 if dedent: |
067540702f64
help: teach topic symbols how to dedent
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24080
diff
changeset
|
663 doclines.append(l.rstrip()) |
067540702f64
help: teach topic symbols how to dedent
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24080
diff
changeset
|
664 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
665 doclines.append(b' ' + l.strip()) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
666 entries.append(b'\n'.join(doclines)) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
667 entries = b'\n\n'.join(entries) |
13593
cc4721ed7a2a
help: extract items doc generation function
Patrick Mezard <pmezard@gmail.com>
parents:
12828
diff
changeset
|
668 return doc.replace(marker, entries) |
14318
1f46be4689ed
help: consolidate topic hooks in help.py
Matt Mackall <mpm@selenic.com>
parents:
14317
diff
changeset
|
669 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
670 |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
671 def addtopicsymbols( |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
672 topic: bytes, marker: bytes, symbols, dedent: bool = False |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
673 ) -> None: |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
674 def add(ui: uimod.ui, topic: bytes, doc: bytes): |
26414
c44b507e7c78
help: pass around ui to rewriter hooks (API)
Yuya Nishihara <yuya@tcha.org>
parents:
26413
diff
changeset
|
675 return makeitemsdoc(ui, topic, doc, marker, symbols, dedent=dedent) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
676 |
14318
1f46be4689ed
help: consolidate topic hooks in help.py
Matt Mackall <mpm@selenic.com>
parents:
14317
diff
changeset
|
677 addtopichook(topic, add) |
1f46be4689ed
help: consolidate topic hooks in help.py
Matt Mackall <mpm@selenic.com>
parents:
14317
diff
changeset
|
678 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
679 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
680 addtopicsymbols( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
681 b'bundlespec', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
682 b'.. bundlecompressionmarker', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
683 compression.bundlecompressiontopics(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
684 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
685 addtopicsymbols(b'filesets', b'.. predicatesmarker', fileset.symbols) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
686 addtopicsymbols( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
687 b'merge-tools', b'.. internaltoolsmarker', filemerge.internalsdoc |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
688 ) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
689 addtopicsymbols(b'revisions', b'.. predicatesmarker', revset.symbols) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
690 addtopicsymbols(b'templates', b'.. keywordsmarker', templatekw.keywords) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
691 addtopicsymbols(b'templates', b'.. filtersmarker', templatefilters.filters) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
692 addtopicsymbols(b'templates', b'.. functionsmarker', templatefuncs.funcs) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
693 addtopicsymbols( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
694 b'hgweb', b'.. webcommandsmarker', webcommands.commands, dedent=True |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
695 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
696 |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
697 |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
698 def inserttweakrc(ui: uimod.ui, topic: bytes, doc: bytes) -> bytes: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
699 marker = b'.. tweakdefaultsmarker' |
40421
e928bedf0919
help: describe what ui.tweakdefaults changes, concretely
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
40295
diff
changeset
|
700 repl = uimod.tweakrc |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
701 |
40421
e928bedf0919
help: describe what ui.tweakdefaults changes, concretely
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
40295
diff
changeset
|
702 def sub(m): |
e928bedf0919
help: describe what ui.tweakdefaults changes, concretely
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
40295
diff
changeset
|
703 lines = [m.group(1) + s for s in repl.splitlines()] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
704 return b'\n'.join(lines) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
705 |
40421
e928bedf0919
help: describe what ui.tweakdefaults changes, concretely
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
40295
diff
changeset
|
706 return re.sub(br'( *)%s' % re.escape(marker), sub, doc) |
e928bedf0919
help: describe what ui.tweakdefaults changes, concretely
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
40295
diff
changeset
|
707 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
708 |
51844
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
709 _CONFIG_DOC_RE = re.compile(b'(^ *)?:config-doc:`([^`]+)`', flags=re.MULTILINE) |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
710 |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
711 |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
712 def sub_config_item_help(ui: uimod.ui, doc: bytes) -> bytes: |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
713 """replace :config-doc:`foo.bar` markup with the item documentation |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
714 |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
715 This allow grouping config item declaration and help without having to |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
716 repeat it in the help text file and keep that in sync. |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
717 """ |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
718 pieces = [] |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
719 last_match_end = 0 |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
720 for match in _CONFIG_DOC_RE.finditer(doc): |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
721 # finditer is expected to yield result in order |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
722 start = match.start() |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
723 assert last_match_end <= match.start() |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
724 pieces.append(doc[last_match_end:start]) |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
725 item_name = match.group(2) |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
726 section, key = item_name.split(b'.', 1) |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
727 section_items = ui._knownconfig.get(section) |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
728 if section_items is None: |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
729 item = None |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
730 else: |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
731 item = section_items.get(key) |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
732 if item is None or not item.documentation: |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
733 item_doc = b'<missing help text for `%s`>' % item_name |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
734 else: |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
735 item_doc = gettext(item.documentation) |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
736 item_doc = sub_config_item_help(ui, item_doc) |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
737 indent = match.group(1) |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
738 if indent: # either None or 0 should be ignored |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
739 indent = indent |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
740 item_doc = indent + item_doc.replace(b'\n', b'\n' + indent) |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
741 pieces.append(item_doc) |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
742 last_match_end = match.end() |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
743 pieces.append(doc[last_match_end:]) |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
744 return b''.join(pieces) |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
745 |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
746 |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
747 def _getcategorizedhelpcmds( |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
748 ui: uimod.ui, cmdtable, name: bytes, select: Optional[_SelectFn] = None |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
749 ) -> Tuple[Dict[bytes, List[bytes]], Dict[bytes, bytes], _SynonymTable]: |
45641
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
750 # Category -> list of commands |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
751 cats = {} |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
752 # Command -> short description |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
753 h = {} |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
754 # Command -> string showing synonyms |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
755 syns = {} |
48913
f254fc73d956
global: bulk replace simple pycompat.iteritems(x) with x.items()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48875
diff
changeset
|
756 for c, e in cmdtable.items(): |
45641
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
757 fs = cmdutil.parsealiases(c) |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
758 f = fs[0] |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
759 syns[f] = fs |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
760 func = e[0] |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
761 if select and not select(f): |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
762 continue |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
763 doc = pycompat.getdoc(func) |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
764 if filtercmd(ui, f, func, name, doc): |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
765 continue |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
766 doc = gettext(doc) |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
767 if not doc: |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
768 doc = _(b"(no help text available)") |
49024
7bd5f862b249
help: use new function for getting first line of string
Martin von Zweigbergk <martinvonz@google.com>
parents:
48923
diff
changeset
|
769 h[f] = stringutil.firstline(doc).rstrip() |
45641
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
770 |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
771 cat = getattr(func, 'helpcategory', None) or ( |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
772 registrar.command.CATEGORY_NONE |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
773 ) |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
774 cats.setdefault(cat, []).append(f) |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
775 return cats, h, syns |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
776 |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
777 |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
778 def _getcategorizedhelptopics( |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
779 ui: uimod.ui, topictable: List[_HelpEntry] |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
780 ) -> Tuple[Dict[bytes, List[Tuple[bytes, bytes]]], Dict[bytes, List[bytes]]]: |
45641
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
781 # Group commands by category. |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
782 topiccats = {} |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
783 syns = {} |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
784 for topic in topictable: |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
785 names, header, doc = topic[0:3] |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
786 if len(topic) > 3 and topic[3]: |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
787 category: bytes = cast(bytes, topic[3]) # help pytype |
45641
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
788 else: |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
789 category: bytes = TOPIC_CATEGORY_NONE |
45641
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
790 |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
791 topicname = names[0] |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
792 syns[topicname] = list(names) |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
793 if not filtertopic(ui, topicname): |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
794 topiccats.setdefault(category, []).append((topicname, header)) |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
795 return topiccats, syns |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
796 |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
797 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
798 addtopichook(b'config', inserttweakrc) |
40421
e928bedf0919
help: describe what ui.tweakdefaults changes, concretely
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
40295
diff
changeset
|
799 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
800 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
801 def help_( |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
802 ui: uimod.ui, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
803 commands, |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
804 name: bytes, |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
805 unknowncmd: bool = False, |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
806 full: bool = True, |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
807 subtopic: Optional[bytes] = None, |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
808 fullname: Optional[bytes] = None, |
51862
607e94e01851
format: add many "missing" comma
Matt Harbison <matt_harbison@yahoo.com>
parents:
51844
diff
changeset
|
809 **opts, |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
810 ) -> bytes: |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45679
diff
changeset
|
811 """ |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
812 Generate the help for 'name' as unformatted restructured text. If |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
813 'name' is None, describe the commands available. |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45679
diff
changeset
|
814 """ |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
815 |
32143
964c6be36590
py3: make sure opts are passed and used correctly in help command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32076
diff
changeset
|
816 opts = pycompat.byteskwargs(opts) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
817 |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
818 def helpcmd(name: bytes, subtopic: Optional[bytes]) -> List[bytes]: |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
819 try: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
820 aliases, entry = cmdutil.findcmd( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
821 name, commands.table, strict=unknowncmd |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
822 ) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24871
diff
changeset
|
823 except error.AmbiguousCommand as inst: |
40263
8cf459d8b111
py3: use py3 as the test tag, dropping the k
Martijn Pieters <mj@octobus.net>
parents:
39614
diff
changeset
|
824 # py3 fix: except vars can't be used outside the scope of the |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
825 # except block, nor can be used inside a lambda. python issue4617 |
45679
65e2b64670b5
errors: name arguments to AmbiguousCommand constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45641
diff
changeset
|
826 prefix = inst.prefix |
36250
4174970c9147
help: use cmdutil.parsealiases() to resolve command name
Yuya Nishihara <yuya@tcha.org>
parents:
36249
diff
changeset
|
827 select = lambda c: cmdutil.parsealiases(c)[0].startswith(prefix) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
828 rst = helplist(select) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
829 return rst |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
830 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
831 rst = [] |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
832 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
833 # check if it's an invalid alias and display its error if it is |
22160
645457f73aa6
alias: keep error message in "badalias" so that help can see it
Yuya Nishihara <yuya@tcha.org>
parents:
22118
diff
changeset
|
834 if getattr(entry[0], 'badalias', None): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
835 rst.append(entry[0].badalias + b'\n') |
22162
7ada34676db8
help: provide help of bad alias without executing aliascmd()
Yuya Nishihara <yuya@tcha.org>
parents:
22160
diff
changeset
|
836 if entry[0].unknowncmd: |
7ada34676db8
help: provide help of bad alias without executing aliascmd()
Yuya Nishihara <yuya@tcha.org>
parents:
22160
diff
changeset
|
837 try: |
7ada34676db8
help: provide help of bad alias without executing aliascmd()
Yuya Nishihara <yuya@tcha.org>
parents:
22160
diff
changeset
|
838 rst.extend(helpextcmd(entry[0].cmdname)) |
7ada34676db8
help: provide help of bad alias without executing aliascmd()
Yuya Nishihara <yuya@tcha.org>
parents:
22160
diff
changeset
|
839 except error.UnknownCommand: |
7ada34676db8
help: provide help of bad alias without executing aliascmd()
Yuya Nishihara <yuya@tcha.org>
parents:
22160
diff
changeset
|
840 pass |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
841 return rst |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
842 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
843 # synopsis |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
844 if len(entry) > 2: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
845 if entry[2].startswith(b'hg'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
846 rst.append(b"%s\n" % entry[2]) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
847 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
848 rst.append(b'hg %s %s\n' % (aliases[0], entry[2])) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
849 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
850 rst.append(b'hg %s\n' % aliases[0]) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
851 # aliases |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
852 if full and not ui.quiet and len(aliases) > 1: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
853 rst.append(_(b"\naliases: %s\n") % b', '.join(aliases[1:])) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
854 rst.append(b'\n') |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
855 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
856 # description |
32615
c9318beb7c1a
py3: convert __doc__ back to bytes in help.py
Yuya Nishihara <yuya@tcha.org>
parents:
32566
diff
changeset
|
857 doc = gettext(pycompat.getdoc(entry[0])) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
858 if not doc: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
859 doc = _(b"(no help text available)") |
50928
d718eddf01d9
safehasattr: drop usage in favor of hasattr
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50621
diff
changeset
|
860 if hasattr(entry[0], 'definition'): # aliased command |
28828
3640c1702c43
help: report source of aliases
timeless <timeless@mozdev.org>
parents:
28523
diff
changeset
|
861 source = entry[0].source |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
862 if entry[0].definition.startswith(b'!'): # shell alias |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
863 doc = _(b'shell alias for: %s\n\n%s\n\ndefined by: %s\n') % ( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
864 entry[0].definition[1:], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
865 doc, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
866 source, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
867 ) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
868 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
869 doc = _(b'alias for: hg %s\n\n%s\n\ndefined by: %s\n') % ( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
870 entry[0].definition, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
871 doc, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
872 source, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
873 ) |
51844
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
874 doc = sub_config_item_help(ui, doc) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
875 doc = doc.splitlines(True) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
876 if ui.quiet or not full: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
877 rst.append(doc[0]) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
878 else: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
879 rst.extend(doc) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
880 rst.append(b'\n') |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
881 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
882 # check if this command shadows a non-trivial (multi-line) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
883 # extension help text |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
884 try: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
885 mod = extensions.find(name) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
886 doc = gettext(pycompat.getdoc(mod)) or b'' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
887 if b'\n' in doc.strip(): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
888 msg = _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
889 b"(use 'hg help -e %s' to show help for " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
890 b"the %s extension)" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
891 ) % (name, name) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
892 rst.append(b'\n%s\n' % msg) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
893 except KeyError: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
894 pass |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
895 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
896 # options |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
897 if not ui.quiet and entry[1]: |
44295
142d2a4cb69a
help: add a mechanism to change flags' help depending on config
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44027
diff
changeset
|
898 rst.append(optrst(_(b"options"), entry[1], ui.verbose, ui)) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
899 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
900 if ui.verbose: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
901 rst.append( |
44306
a0ec05d93c8e
cleanup: re-run black on the codebase
Augie Fackler <augie@google.com>
parents:
44295
diff
changeset
|
902 optrst( |
a0ec05d93c8e
cleanup: re-run black on the codebase
Augie Fackler <augie@google.com>
parents:
44295
diff
changeset
|
903 _(b"global options"), commands.globalopts, ui.verbose, ui |
a0ec05d93c8e
cleanup: re-run black on the codebase
Augie Fackler <augie@google.com>
parents:
44295
diff
changeset
|
904 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
905 ) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
906 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
907 if not ui.verbose: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
908 if not full: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
909 rst.append(_(b"\n(use 'hg %s -h' to show more help)\n") % name) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
910 elif not ui.quiet: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
911 rst.append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
912 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
913 b'\n(some details hidden, use --verbose ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
914 b'to show complete help)' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
915 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
916 ) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
917 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
918 return rst |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
919 |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
920 def helplist(select: Optional[_SelectFn] = None, **opts) -> List[bytes]: |
45641
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
921 cats, h, syns = _getcategorizedhelpcmds( |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
922 ui, commands.table, name, select |
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
923 ) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
924 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
925 rst = [] |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
926 if not h: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
927 if not ui.quiet: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
928 rst.append(_(b'no commands defined\n')) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
929 return rst |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
930 |
40291
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
931 # Output top header. |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
932 if not ui.quiet: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
933 if name == b"shortlist": |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
934 rst.append(_(b'basic commands:\n\n')) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
935 elif name == b"debug": |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
936 rst.append(_(b'debug commands (internal and unsupported):\n\n')) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
937 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
938 rst.append(_(b'list of commands:\n')) |
40291
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
939 |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
940 def appendcmds(cmds: Iterable[bytes]) -> None: |
40291
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
941 cmds = sorted(cmds) |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
942 for c in cmds: |
46386
d481f30ea8e3
help: escape ':' (as '\:') when generating command names
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46261
diff
changeset
|
943 display_cmd = c |
40291
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
944 if ui.verbose: |
46386
d481f30ea8e3
help: escape ':' (as '\:') when generating command names
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46261
diff
changeset
|
945 display_cmd = b', '.join(syns[c]) |
d481f30ea8e3
help: escape ':' (as '\:') when generating command names
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46261
diff
changeset
|
946 display_cmd = display_cmd.replace(b':', br'\:') |
d481f30ea8e3
help: escape ':' (as '\:') when generating command names
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46261
diff
changeset
|
947 rst.append(b' :%s: %s\n' % (display_cmd, h[c])) |
40291
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
948 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
949 if name in (b'shortlist', b'debug'): |
40291
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
950 # List without categories. |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
951 appendcmds(h) |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
952 else: |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
953 # Check that all categories have an order. |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
954 missing_order = set(cats.keys()) - set(CATEGORY_ORDER) |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
955 if missing_order: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
956 ui.develwarn( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
957 b'help categories missing from CATEGORY_ORDER: %s' |
49628
f09bc2ed9100
help: fix a py3 error interpolating Set into b'%s'
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
958 % stringutil.forcebytestr(missing_order) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
959 ) |
40291
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
960 |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
961 # List per category. |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
962 for cat in CATEGORY_ORDER: |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
963 catfns = cats.get(cat, []) |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
964 if catfns: |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
965 if len(cats) > 1: |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
966 catname = gettext(CATEGORY_NAMES[cat]) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
967 rst.append(b"\n%s:\n" % catname) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
968 rst.append(b"\n") |
40291
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
969 appendcmds(catfns) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
970 |
27325
eadbbd14bdc1
help: fix help -c/help -e/help -k
timeless <timeless@mozdev.org>
parents:
27324
diff
changeset
|
971 ex = opts.get |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43117
diff
changeset
|
972 anyopts = ex('keyword') or not (ex('command') or ex('extension')) |
27325
eadbbd14bdc1
help: fix help -c/help -e/help -k
timeless <timeless@mozdev.org>
parents:
27324
diff
changeset
|
973 if not name and anyopts: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
974 exts = listexts( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
975 _(b'enabled extensions:'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
976 extensions.enabled(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
977 showdeprecated=ui.verbose, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
978 ) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
979 if exts: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
980 rst.append(b'\n') |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
981 rst.extend(exts) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
982 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
983 rst.append(_(b"\nadditional help topics:\n")) |
45641
65cb924a1430
help: extract logic for listing commands and topics
Ludovic Chabant <ludovic@chabant.com>
parents:
45059
diff
changeset
|
984 topiccats, topicsyns = _getcategorizedhelptopics(ui, helptable) |
40292
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
985 |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
986 # Check that all categories have an order. |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
987 missing_order = set(topiccats.keys()) - set(TOPIC_CATEGORY_ORDER) |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
988 if missing_order: |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
989 ui.develwarn( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
990 b'help categories missing from TOPIC_CATEGORY_ORDER: %s' |
49628
f09bc2ed9100
help: fix a py3 error interpolating Set into b'%s'
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
991 % stringutil.forcebytestr(missing_order) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
992 ) |
40292
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
993 |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
994 # Output topics per category. |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
995 for cat in TOPIC_CATEGORY_ORDER: |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
996 topics = topiccats.get(cat, []) |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
997 if topics: |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
998 if len(topiccats) > 1: |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
999 catname = gettext(TOPIC_CATEGORY_NAMES[cat]) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1000 rst.append(b"\n%s:\n" % catname) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1001 rst.append(b"\n") |
40292
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
1002 for t, desc in topics: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1003 rst.append(b" :%s: %s\n" % (t, desc)) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1004 |
22115
8465625f7364
help: refactor helplist optlist mess
Matt Mackall <mpm@selenic.com>
parents:
22114
diff
changeset
|
1005 if ui.quiet: |
8465625f7364
help: refactor helplist optlist mess
Matt Mackall <mpm@selenic.com>
parents:
22114
diff
changeset
|
1006 pass |
8465625f7364
help: refactor helplist optlist mess
Matt Mackall <mpm@selenic.com>
parents:
22114
diff
changeset
|
1007 elif ui.verbose: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1008 rst.append( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1009 b'\n%s\n' |
44306
a0ec05d93c8e
cleanup: re-run black on the codebase
Augie Fackler <augie@google.com>
parents:
44295
diff
changeset
|
1010 % optrst( |
a0ec05d93c8e
cleanup: re-run black on the codebase
Augie Fackler <augie@google.com>
parents:
44295
diff
changeset
|
1011 _(b"global options"), commands.globalopts, ui.verbose, ui |
a0ec05d93c8e
cleanup: re-run black on the codebase
Augie Fackler <augie@google.com>
parents:
44295
diff
changeset
|
1012 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1013 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1014 if name == b'shortlist': |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1015 rst.append( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
1016 _(b"\n(use 'hg help' for the full list of commands)\n") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1017 ) |
22115
8465625f7364
help: refactor helplist optlist mess
Matt Mackall <mpm@selenic.com>
parents:
22114
diff
changeset
|
1018 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1019 if name == b'shortlist': |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1020 rst.append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1021 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1022 b"\n(use 'hg help' for the full list of commands " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1023 b"or 'hg -v' for details)\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1024 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1025 ) |
22115
8465625f7364
help: refactor helplist optlist mess
Matt Mackall <mpm@selenic.com>
parents:
22114
diff
changeset
|
1026 elif name and not full: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1027 rst.append( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
1028 _(b"\n(use 'hg help %s' to show the full help text)\n") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1029 % name |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1030 ) |
40291
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
1031 elif name and syns and name in syns.keys(): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1032 rst.append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1033 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1034 b"\n(use 'hg help -v -e %s' to show built-in " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1035 b"aliases and global options)\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1036 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1037 % name |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1038 ) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1039 else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1040 rst.append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1041 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1042 b"\n(use 'hg help -v%s' to show built-in aliases " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1043 b"and global options)\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1044 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1045 % (name and b" " + name or b"") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1046 ) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1047 return rst |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1048 |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
1049 def helptopic(name: bytes, subtopic: Optional[bytes] = None) -> List[bytes]: |
27379
2278870bb997
help: support loading sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27378
diff
changeset
|
1050 # Look for sub-topic entry first. |
2278870bb997
help: support loading sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27378
diff
changeset
|
1051 header, doc = None, None |
2278870bb997
help: support loading sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27378
diff
changeset
|
1052 if subtopic and name in subtopics: |
2278870bb997
help: support loading sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27378
diff
changeset
|
1053 for names, header, doc in subtopics[name]: |
2278870bb997
help: support loading sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27378
diff
changeset
|
1054 if subtopic in names: |
2278870bb997
help: support loading sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27378
diff
changeset
|
1055 break |
42393
a84564b1a0b1
help: check if a subtopic exists and raise an error if it doesn't (issue6145)
Nathan Goldbaum <nathan12343@gmail.com>
parents:
42057
diff
changeset
|
1056 if not any(subtopic in s[0] for s in subtopics[name]): |
a84564b1a0b1
help: check if a subtopic exists and raise an error if it doesn't (issue6145)
Nathan Goldbaum <nathan12343@gmail.com>
parents:
42057
diff
changeset
|
1057 raise error.UnknownCommand(name) |
27379
2278870bb997
help: support loading sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27378
diff
changeset
|
1058 |
2278870bb997
help: support loading sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27378
diff
changeset
|
1059 if not header: |
40292
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
1060 for topic in helptable: |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
1061 names, header, doc = topic[0:3] |
27379
2278870bb997
help: support loading sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27378
diff
changeset
|
1062 if name in names: |
2278870bb997
help: support loading sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27378
diff
changeset
|
1063 break |
2278870bb997
help: support loading sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27378
diff
changeset
|
1064 else: |
2278870bb997
help: support loading sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27378
diff
changeset
|
1065 raise error.UnknownCommand(name) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1066 |
18748
6e676fb6ea44
help: use a full header for topic titles
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
18746
diff
changeset
|
1067 rst = [minirst.section(header)] |
6e676fb6ea44
help: use a full header for topic titles
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
18746
diff
changeset
|
1068 |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1069 # description |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1070 if not doc: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1071 rst.append(b" %s\n" % _(b"(no help text available)")) |
21796
8225bb1f0ad3
help: restore use of callable() since it was readded in Python 3.2
Augie Fackler <raf@durin42.com>
parents:
21289
diff
changeset
|
1072 if callable(doc): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1073 rst += [b" %s\n" % l for l in doc(ui).splitlines()] |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1074 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1075 if not ui.verbose: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1076 omitted = _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1077 b'(some details hidden, use --verbose' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1078 b' to show complete help)' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1079 ) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1080 indicateomitted(rst, omitted) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1081 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1082 try: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1083 cmdutil.findcmd(name, commands.table) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1084 rst.append( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
1085 _(b"\nuse 'hg help -c %s' to see help for the %s command\n") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1086 % (name, name) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1087 ) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1088 except error.UnknownCommand: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1089 pass |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1090 return rst |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1091 |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
1092 def helpext(name: bytes, subtopic: Optional[bytes] = None) -> List[bytes]: |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1093 try: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1094 mod = extensions.find(name) |
51844
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
1095 doc = ext_help(ui, mod) |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
1096 if not doc: |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
1097 doc = _(b'no help text available') |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1098 except KeyError: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1099 mod = None |
44657
843418dc0b1b
extensions: refactor function for obtaining disabled extension help
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44306
diff
changeset
|
1100 doc = extensions.disabled_help(name) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1101 if not doc: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1102 raise error.UnknownCommand(name) |
51844
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50929
diff
changeset
|
1103 doc = sub_config_item_help(ui, doc) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1104 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1105 if b'\n' not in doc: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1106 head, tail = doc, b"" |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1107 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1108 head, tail = doc.split(b'\n', 1) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1109 rst = [_(b'%s extension - %s\n\n') % (name.rpartition(b'.')[-1], head)] |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1110 if tail: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1111 rst.extend(tail.splitlines(True)) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1112 rst.append(b'\n') |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1113 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1114 if not ui.verbose: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1115 omitted = _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1116 b'(some details hidden, use --verbose' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1117 b' to show complete help)' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1118 ) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1119 indicateomitted(rst, omitted) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1120 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1121 if mod: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1122 try: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1123 ct = mod.cmdtable |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1124 except AttributeError: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1125 ct = {} |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1126 modcmds = {c.partition(b'|')[0] for c in ct} |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1127 rst.extend(helplist(modcmds.__contains__)) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1128 else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1129 rst.append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1130 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1131 b"(use 'hg help extensions' for information on enabling" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1132 b" extensions)\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1133 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1134 ) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1135 return rst |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1136 |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
1137 def helpextcmd( |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
1138 name: bytes, subtopic: Optional[bytes] = None |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
1139 ) -> List[bytes]: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1140 cmd, ext, doc = extensions.disabledcmd( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1141 ui, name, ui.configbool(b'ui', b'strict') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1142 ) |
49024
7bd5f862b249
help: use new function for getting first line of string
Martin von Zweigbergk <martinvonz@google.com>
parents:
48923
diff
changeset
|
1143 doc = stringutil.firstline(doc) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1144 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1145 rst = listexts( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
1146 _(b"'%s' is provided by the following extension:") % cmd, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1147 {ext: doc}, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1148 indent=4, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1149 showdeprecated=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1150 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1151 rst.append(b'\n') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1152 rst.append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1153 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1154 b"(use 'hg help extensions' for information on enabling " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1155 b"extensions)\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1156 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1157 ) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1158 return rst |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1159 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1160 rst = [] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1161 kw = opts.get(b'keyword') |
27325
eadbbd14bdc1
help: fix help -c/help -e/help -k
timeless <timeless@mozdev.org>
parents:
27324
diff
changeset
|
1162 if kw or name is None and any(opts[o] for o in opts): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1163 matches = topicmatch(ui, commands, name or b'') |
26238
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
1164 helpareas = [] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1165 if opts.get(b'extension'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1166 helpareas += [(b'extensions', _(b'Extensions'))] |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1167 if opts.get(b'command'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1168 helpareas += [(b'commands', _(b'Commands'))] |
26238
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
1169 if not helpareas: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1170 helpareas = [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1171 (b'topics', _(b'Topics')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1172 (b'commands', _(b'Commands')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1173 (b'extensions', _(b'Extensions')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1174 (b'extensioncommands', _(b'Extension Commands')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1175 ] |
26238
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
1176 for t, title in helpareas: |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1177 if matches[t]: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1178 rst.append(b'%s:\n\n' % title) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1179 rst.extend(minirst.maketable(sorted(matches[t]), 1)) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1180 rst.append(b'\n') |
21288
eb6eaef7ae44
help: provide a more helpful message when no keyword are matched
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20823
diff
changeset
|
1181 if not rst: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1182 msg = _(b'no matches') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1183 hint = _(b"try 'hg help' for a list of topics") |
46261
c9b2a4d69e66
errors: raise InputError when non-existent help section requested
Martin von Zweigbergk <martinvonz@google.com>
parents:
45942
diff
changeset
|
1184 raise error.InputError(msg, hint=hint) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1185 elif name and name != b'shortlist': |
26238
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
1186 queries = [] |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1187 if unknowncmd: |
26238
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
1188 queries += [helpextcmd] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1189 if opts.get(b'extension'): |
26238
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
1190 queries += [helpext] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1191 if opts.get(b'command'): |
26238
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
1192 queries += [helpcmd] |
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
1193 if not queries: |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1194 queries = (helptopic, helpcmd, helpext, helpextcmd) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1195 for f in queries: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1196 try: |
27378
c709b515218e
help: pass sub-topic into help query functions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27377
diff
changeset
|
1197 rst = f(name, subtopic) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1198 break |
21289
c3784e3c3e8d
help: suggest keyword search when no topic is found
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21288
diff
changeset
|
1199 except error.UnknownCommand: |
c3784e3c3e8d
help: suggest keyword search when no topic is found
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21288
diff
changeset
|
1200 pass |
c3784e3c3e8d
help: suggest keyword search when no topic is found
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21288
diff
changeset
|
1201 else: |
c3784e3c3e8d
help: suggest keyword search when no topic is found
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21288
diff
changeset
|
1202 if unknowncmd: |
c3784e3c3e8d
help: suggest keyword search when no topic is found
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21288
diff
changeset
|
1203 raise error.UnknownCommand(name) |
c3784e3c3e8d
help: suggest keyword search when no topic is found
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21288
diff
changeset
|
1204 else: |
42394
ad55a0a5894f
help: include subtopic in error message if passed
Nathan Goldbaum <nathan12343@gmail.com>
parents:
42393
diff
changeset
|
1205 if fullname: |
ad55a0a5894f
help: include subtopic in error message if passed
Nathan Goldbaum <nathan12343@gmail.com>
parents:
42393
diff
changeset
|
1206 formatname = fullname |
ad55a0a5894f
help: include subtopic in error message if passed
Nathan Goldbaum <nathan12343@gmail.com>
parents:
42393
diff
changeset
|
1207 else: |
ad55a0a5894f
help: include subtopic in error message if passed
Nathan Goldbaum <nathan12343@gmail.com>
parents:
42393
diff
changeset
|
1208 formatname = name |
ad55a0a5894f
help: include subtopic in error message if passed
Nathan Goldbaum <nathan12343@gmail.com>
parents:
42393
diff
changeset
|
1209 if subtopic: |
ad55a0a5894f
help: include subtopic in error message if passed
Nathan Goldbaum <nathan12343@gmail.com>
parents:
42393
diff
changeset
|
1210 hintname = subtopic |
ad55a0a5894f
help: include subtopic in error message if passed
Nathan Goldbaum <nathan12343@gmail.com>
parents:
42393
diff
changeset
|
1211 else: |
ad55a0a5894f
help: include subtopic in error message if passed
Nathan Goldbaum <nathan12343@gmail.com>
parents:
42393
diff
changeset
|
1212 hintname = name |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1213 msg = _(b'no such help topic: %s') % formatname |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1214 hint = _(b"try 'hg help --keyword %s'") % hintname |
46261
c9b2a4d69e66
errors: raise InputError when non-existent help section requested
Martin von Zweigbergk <martinvonz@google.com>
parents:
45942
diff
changeset
|
1215 raise error.InputError(msg, hint=hint) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1216 else: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1217 # program name |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1218 if not ui.quiet: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1219 rst = [_(b"Mercurial Distributed SCM\n"), b'\n'] |
32547
0cec8ad579d4
help: convert dict to strkwargs
Augie Fackler <raf@durin42.com>
parents:
32291
diff
changeset
|
1220 rst.extend(helplist(None, **pycompat.strkwargs(opts))) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1221 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1222 return b''.join(rst) |
31059
2a0c8e3636b0
help: move rst formatting of help documents into help.py
Augie Fackler <augie@google.com>
parents:
30812
diff
changeset
|
1223 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1224 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1225 def formattedhelp( |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
1226 ui: uimod.ui, |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
1227 commands, |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
1228 fullname: Optional[bytes], |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
1229 keep: Optional[Iterable[bytes]] = None, |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
1230 unknowncmd: bool = False, |
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
1231 full: bool = True, |
51862
607e94e01851
format: add many "missing" comma
Matt Harbison <matt_harbison@yahoo.com>
parents:
51844
diff
changeset
|
1232 **opts, |
49646
2a70d1fc70c4
typing: add type hints to mercurial/help.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
49565
diff
changeset
|
1233 ) -> bytes: |
31059
2a0c8e3636b0
help: move rst formatting of help documents into help.py
Augie Fackler <augie@google.com>
parents:
30812
diff
changeset
|
1234 """get help for a given topic (as a dotted name) as rendered rst |
2a0c8e3636b0
help: move rst formatting of help documents into help.py
Augie Fackler <augie@google.com>
parents:
30812
diff
changeset
|
1235 |
2a0c8e3636b0
help: move rst formatting of help documents into help.py
Augie Fackler <augie@google.com>
parents:
30812
diff
changeset
|
1236 Either returns the rendered help text or raises an exception. |
2a0c8e3636b0
help: move rst formatting of help documents into help.py
Augie Fackler <augie@google.com>
parents:
30812
diff
changeset
|
1237 """ |
2a0c8e3636b0
help: move rst formatting of help documents into help.py
Augie Fackler <augie@google.com>
parents:
30812
diff
changeset
|
1238 if keep is None: |
2a0c8e3636b0
help: move rst formatting of help documents into help.py
Augie Fackler <augie@google.com>
parents:
30812
diff
changeset
|
1239 keep = [] |
31265
79715ba22f9c
help: avoid mutating passed-in `keep` list in `formattedhelp`
Augie Fackler <augie@google.com>
parents:
31129
diff
changeset
|
1240 else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1241 keep = list(keep) # make a copy so we can mutate this later |
39339
d30867a745a1
help: rewrite parsing of help topic to not drop section name with dots
Yuya Nishihara <yuya@tcha.org>
parents:
39309
diff
changeset
|
1242 |
d30867a745a1
help: rewrite parsing of help topic to not drop section name with dots
Yuya Nishihara <yuya@tcha.org>
parents:
39309
diff
changeset
|
1243 # <fullname> := <name>[.<subtopic][.<section>] |
d30867a745a1
help: rewrite parsing of help topic to not drop section name with dots
Yuya Nishihara <yuya@tcha.org>
parents:
39309
diff
changeset
|
1244 name = subtopic = section = None |
d30867a745a1
help: rewrite parsing of help topic to not drop section name with dots
Yuya Nishihara <yuya@tcha.org>
parents:
39309
diff
changeset
|
1245 if fullname is not None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1246 nameparts = fullname.split(b'.') |
39339
d30867a745a1
help: rewrite parsing of help topic to not drop section name with dots
Yuya Nishihara <yuya@tcha.org>
parents:
39309
diff
changeset
|
1247 name = nameparts.pop(0) |
d30867a745a1
help: rewrite parsing of help topic to not drop section name with dots
Yuya Nishihara <yuya@tcha.org>
parents:
39309
diff
changeset
|
1248 if nameparts and name in subtopics: |
d30867a745a1
help: rewrite parsing of help topic to not drop section name with dots
Yuya Nishihara <yuya@tcha.org>
parents:
39309
diff
changeset
|
1249 subtopic = nameparts.pop(0) |
d30867a745a1
help: rewrite parsing of help topic to not drop section name with dots
Yuya Nishihara <yuya@tcha.org>
parents:
39309
diff
changeset
|
1250 if nameparts: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1251 section = encoding.lower(b'.'.join(nameparts)) |
39339
d30867a745a1
help: rewrite parsing of help topic to not drop section name with dots
Yuya Nishihara <yuya@tcha.org>
parents:
39309
diff
changeset
|
1252 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1253 textwidth = ui.configint(b'ui', b'textwidth') |
31059
2a0c8e3636b0
help: move rst formatting of help documents into help.py
Augie Fackler <augie@google.com>
parents:
30812
diff
changeset
|
1254 termwidth = ui.termwidth() - 2 |
2a0c8e3636b0
help: move rst formatting of help documents into help.py
Augie Fackler <augie@google.com>
parents:
30812
diff
changeset
|
1255 if textwidth <= 0 or termwidth < textwidth: |
2a0c8e3636b0
help: move rst formatting of help documents into help.py
Augie Fackler <augie@google.com>
parents:
30812
diff
changeset
|
1256 textwidth = termwidth |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1257 text = help_( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1258 ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1259 commands, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1260 name, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1261 fullname=fullname, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1262 subtopic=subtopic, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1263 unknowncmd=unknowncmd, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1264 full=full, |
51862
607e94e01851
format: add many "missing" comma
Matt Harbison <matt_harbison@yahoo.com>
parents:
51844
diff
changeset
|
1265 **opts, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42450
diff
changeset
|
1266 ) |
31059
2a0c8e3636b0
help: move rst formatting of help documents into help.py
Augie Fackler <augie@google.com>
parents:
30812
diff
changeset
|
1267 |
39308
9b800601701c
help: inline minirst.format()
Yuya Nishihara <yuya@tcha.org>
parents:
37998
diff
changeset
|
1268 blocks, pruned = minirst.parse(text, keep=keep) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1269 if b'verbose' in pruned: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1270 keep.append(b'omitted') |
31059
2a0c8e3636b0
help: move rst formatting of help documents into help.py
Augie Fackler <augie@google.com>
parents:
30812
diff
changeset
|
1271 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1272 keep.append(b'notomitted') |
39308
9b800601701c
help: inline minirst.format()
Yuya Nishihara <yuya@tcha.org>
parents:
37998
diff
changeset
|
1273 blocks, pruned = minirst.parse(text, keep=keep) |
9b800601701c
help: inline minirst.format()
Yuya Nishihara <yuya@tcha.org>
parents:
37998
diff
changeset
|
1274 if section: |
9b800601701c
help: inline minirst.format()
Yuya Nishihara <yuya@tcha.org>
parents:
37998
diff
changeset
|
1275 blocks = minirst.filtersections(blocks, section) |
39309
0a766cb1092a
help: reorder section filtering flow to not format help text twice
Yuya Nishihara <yuya@tcha.org>
parents:
39308
diff
changeset
|
1276 |
0a766cb1092a
help: reorder section filtering flow to not format help text twice
Yuya Nishihara <yuya@tcha.org>
parents:
39308
diff
changeset
|
1277 # We could have been given a weird ".foo" section without a name |
0a766cb1092a
help: reorder section filtering flow to not format help text twice
Yuya Nishihara <yuya@tcha.org>
parents:
39308
diff
changeset
|
1278 # to look for, or we could have simply failed to found "foo.bar" |
0a766cb1092a
help: reorder section filtering flow to not format help text twice
Yuya Nishihara <yuya@tcha.org>
parents:
39308
diff
changeset
|
1279 # because bar isn't a section of foo |
0a766cb1092a
help: reorder section filtering flow to not format help text twice
Yuya Nishihara <yuya@tcha.org>
parents:
39308
diff
changeset
|
1280 if section and not (blocks and name): |
46261
c9b2a4d69e66
errors: raise InputError when non-existent help section requested
Martin von Zweigbergk <martinvonz@google.com>
parents:
45942
diff
changeset
|
1281 raise error.InputError(_(b"help section not found: %s") % fullname) |
39309
0a766cb1092a
help: reorder section filtering flow to not format help text twice
Yuya Nishihara <yuya@tcha.org>
parents:
39308
diff
changeset
|
1282 |
39308
9b800601701c
help: inline minirst.format()
Yuya Nishihara <yuya@tcha.org>
parents:
37998
diff
changeset
|
1283 return minirst.formatplain(blocks, textwidth) |