Show More
@@ -170,7 +170,7 b' logopts = [' | |||||
170 |
|
170 | |||
171 | diffopts = [ |
|
171 | diffopts = [ | |
172 | (b'a', b'text', None, _(b'treat all files as text')), |
|
172 | (b'a', b'text', None, _(b'treat all files as text')), | |
173 | (b'g', b'git', None, _(b'use git extended diff format')), |
|
173 | (b'g', b'git', None, _(b'use git extended diff format (DEFAULT: diff.git)')), | |
174 | (b'', b'binary', None, _(b'generate binary diffs in git mode (default)')), |
|
174 | (b'', b'binary', None, _(b'generate binary diffs in git mode (default)')), | |
175 | (b'', b'nodates', None, _(b'omit dates from diff headers')), |
|
175 | (b'', b'nodates', None, _(b'omit dates from diff headers')), | |
176 | ] |
|
176 | ] |
@@ -152,8 +152,17 b' def extshelp(ui):' | |||||
152 | doc = b''.join(rst) |
|
152 | doc = b''.join(rst) | |
153 | return doc |
|
153 | return doc | |
154 |
|
154 | |||
|
155 | def parsedefaultmarker(text): | |||
|
156 | """given a text 'abc (DEFAULT: def.ghi)', | |||
|
157 | returns (b'abc', (b'def', b'ghi')). Otherwise return None""" | |||
|
158 | if text[-1:] == b')': | |||
|
159 | marker = b' (DEFAULT: ' | |||
|
160 | pos = text.find(marker) | |||
|
161 | if pos >= 0: | |||
|
162 | item = text[pos + len(marker):-1] | |||
|
163 | return text[:pos], item.split(b'.', 2) | |||
155 |
|
164 | |||
156 | def optrst(header, options, verbose): |
|
165 | def optrst(header, options, verbose, ui): | |
157 | data = [] |
|
166 | data = [] | |
158 | multioccur = False |
|
167 | multioccur = False | |
159 | for option in options: |
|
168 | for option in options: | |
@@ -165,7 +174,14 b' def optrst(header, options, verbose):' | |||||
165 |
|
174 | |||
166 | if not verbose and any(w in desc for w in _exclkeywords): |
|
175 | if not verbose and any(w in desc for w in _exclkeywords): | |
167 | continue |
|
176 | continue | |
168 |
|
177 | defaultstrsuffix = b'' | ||
|
178 | if default is None: | |||
|
179 | parseresult = parsedefaultmarker(desc) | |||
|
180 | if parseresult is not None: | |||
|
181 | (desc, (section, name)) = parseresult | |||
|
182 | if ui.configbool(section, name): | |||
|
183 | default = True | |||
|
184 | defaultstrsuffix = _(b' from config') | |||
169 | so = b'' |
|
185 | so = b'' | |
170 | if shortopt: |
|
186 | if shortopt: | |
171 | so = b'-' + shortopt |
|
187 | so = b'-' + shortopt | |
@@ -183,7 +199,7 b' def optrst(header, options, verbose):' | |||||
183 | defaultstr = pycompat.bytestr(default) |
|
199 | defaultstr = pycompat.bytestr(default) | |
184 | if default is True: |
|
200 | if default is True: | |
185 | defaultstr = _(b"on") |
|
201 | defaultstr = _(b"on") | |
186 | desc += _(b" (default: %s)") % defaultstr |
|
202 | desc += _(b" (default: %s)") % (defaultstr + defaultstrsuffix) | |
187 |
|
203 | |||
188 | if isinstance(default, list): |
|
204 | if isinstance(default, list): | |
189 | lo += b" %s [+]" % optlabel |
|
205 | lo += b" %s [+]" % optlabel | |
@@ -714,11 +730,11 b' def help_(' | |||||
714 |
|
730 | |||
715 | # options |
|
731 | # options | |
716 | if not ui.quiet and entry[1]: |
|
732 | if not ui.quiet and entry[1]: | |
717 | rst.append(optrst(_(b"options"), entry[1], ui.verbose)) |
|
733 | rst.append(optrst(_(b"options"), entry[1], ui.verbose, ui)) | |
718 |
|
734 | |||
719 | if ui.verbose: |
|
735 | if ui.verbose: | |
720 | rst.append( |
|
736 | rst.append( | |
721 | optrst(_(b"global options"), commands.globalopts, ui.verbose) |
|
737 | optrst(_(b"global options"), commands.globalopts, ui.verbose, ui) | |
722 | ) |
|
738 | ) | |
723 |
|
739 | |||
724 | if not ui.verbose: |
|
740 | if not ui.verbose: | |
@@ -858,7 +874,7 b' def help_(' | |||||
858 | elif ui.verbose: |
|
874 | elif ui.verbose: | |
859 | rst.append( |
|
875 | rst.append( | |
860 | b'\n%s\n' |
|
876 | b'\n%s\n' | |
861 | % optrst(_(b"global options"), commands.globalopts, ui.verbose) |
|
877 | % optrst(_(b"global options"), commands.globalopts, ui.verbose, ui) | |
862 | ) |
|
878 | ) | |
863 | if name == b'shortlist': |
|
879 | if name == b'shortlist': | |
864 | rst.append( |
|
880 | rst.append( |
@@ -788,6 +788,12 b' Disabled extension gets suggested' | |||||
788 | (use 'hg help extensions' for information on enabling extensions) |
|
788 | (use 'hg help extensions' for information on enabling extensions) | |
789 | [255] |
|
789 | [255] | |
790 |
|
790 | |||
|
791 | Checking that help adapts based on the config: | |||
|
792 | ||||
|
793 | $ hg help diff --config ui.tweakdefaults=true | egrep -e '^ *(-g|config)' | |||
|
794 | -g --[no-]git use git extended diff format (default: on from | |||
|
795 | config) | |||
|
796 | ||||
791 | Make sure that we don't run afoul of the help system thinking that |
|
797 | Make sure that we don't run afoul of the help system thinking that | |
792 | this is a section and erroring out weirdly. |
|
798 | this is a section and erroring out weirdly. | |
793 |
|
799 |
General Comments 0
You need to be logged in to leave comments.
Login now