Show More
@@ -170,7 +170,7 b' logopts = [' | |||
|
170 | 170 | |
|
171 | 171 | diffopts = [ |
|
172 | 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 | 174 | (b'', b'binary', None, _(b'generate binary diffs in git mode (default)')), |
|
175 | 175 | (b'', b'nodates', None, _(b'omit dates from diff headers')), |
|
176 | 176 | ] |
@@ -152,8 +152,17 b' def extshelp(ui):' | |||
|
152 | 152 | doc = b''.join(rst) |
|
153 | 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 | 166 | data = [] |
|
158 | 167 | multioccur = False |
|
159 | 168 | for option in options: |
@@ -165,7 +174,14 b' def optrst(header, options, verbose):' | |||
|
165 | 174 | |
|
166 | 175 | if not verbose and any(w in desc for w in _exclkeywords): |
|
167 | 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 | 185 | so = b'' |
|
170 | 186 | if shortopt: |
|
171 | 187 | so = b'-' + shortopt |
@@ -183,7 +199,7 b' def optrst(header, options, verbose):' | |||
|
183 | 199 | defaultstr = pycompat.bytestr(default) |
|
184 | 200 | if default is True: |
|
185 | 201 | defaultstr = _(b"on") |
|
186 | desc += _(b" (default: %s)") % defaultstr | |
|
202 | desc += _(b" (default: %s)") % (defaultstr + defaultstrsuffix) | |
|
187 | 203 | |
|
188 | 204 | if isinstance(default, list): |
|
189 | 205 | lo += b" %s [+]" % optlabel |
@@ -714,11 +730,11 b' def help_(' | |||
|
714 | 730 | |
|
715 | 731 | # options |
|
716 | 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 | 735 | if ui.verbose: |
|
720 | 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 | 740 | if not ui.verbose: |
@@ -858,7 +874,7 b' def help_(' | |||
|
858 | 874 | elif ui.verbose: |
|
859 | 875 | rst.append( |
|
860 | 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 | 879 | if name == b'shortlist': |
|
864 | 880 | rst.append( |
@@ -788,6 +788,12 b' Disabled extension gets suggested' | |||
|
788 | 788 | (use 'hg help extensions' for information on enabling extensions) |
|
789 | 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 | 797 | Make sure that we don't run afoul of the help system thinking that |
|
792 | 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