equal
deleted
inserted
replaced
150 ) |
150 ) |
151 ) |
151 ) |
152 doc = b''.join(rst) |
152 doc = b''.join(rst) |
153 return doc |
153 return doc |
154 |
154 |
155 |
155 def parsedefaultmarker(text): |
156 def optrst(header, options, verbose): |
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) |
|
164 |
|
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: |
160 if len(option) == 5: |
169 if len(option) == 5: |
161 shortopt, longopt, default, desc, optlabel = option |
170 shortopt, longopt, default, desc, optlabel = option |
163 shortopt, longopt, default, desc = option |
172 shortopt, longopt, default, desc = option |
164 optlabel = _(b"VALUE") # default label |
173 optlabel = _(b"VALUE") # default label |
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 |
172 lo = b'--' + longopt |
188 lo = b'--' + longopt |
173 if default is True: |
189 if default is True: |
181 # match that behavior on Python 3, we do str(default) and |
197 # match that behavior on Python 3, we do str(default) and |
182 # then convert it to bytes. |
198 # then convert it to bytes. |
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 |
190 multioccur = True |
206 multioccur = True |
191 elif (default is not None) and not isinstance(default, bool): |
207 elif (default is not None) and not isinstance(default, bool): |
712 except KeyError: |
728 except KeyError: |
713 pass |
729 pass |
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: |
725 if not full: |
741 if not full: |
726 rst.append(_(b"\n(use 'hg %s -h' to show more help)\n") % name) |
742 rst.append(_(b"\n(use 'hg %s -h' to show more help)\n") % name) |
856 if ui.quiet: |
872 if ui.quiet: |
857 pass |
873 pass |
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( |
865 _(b"\n(use 'hg help' for the full list of commands)\n") |
881 _(b"\n(use 'hg help' for the full list of commands)\n") |
866 ) |
882 ) |