comparison mercurial/commands.py @ 17837:b623e323c561

help: indicate help omitting if help document is not fully displayed Before this patch, there is no information about whether help document is fully displayed or not. So, some users seem to misunderstand "-v" for "hg help" just as "the option to show list of global options": experience on "hg help -v" for some commands not containing verbose containers may strengthen this misunderstanding. Such users have less opportunity for noticing omitted help document, and this may cause insufficient understanding about Mercurial. This patch indicates help omitting, if help document is not fully displayed. For command help, the message below is displayed at the end of help output, if help document is not fully displayed: use "hg -v help xxxx" to show more complete help and the global options and otherwise: use "hg -v help xxxx" to show the global options For topics and extensions help, the message below is displayed, only if help document is not fully displayed: use "hg help -v xxxx" to show more complete help This allows users to know whether there is any omitted information or not exactly, and can trigger "hg help -v" invocation. This patch causes formatting help document twice, to switch messages one for omitted help, and another for not omitted. This decreases performance of help document formatting, but it is not mainly focused at help command invocation, so this wouldn't become problem.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Thu, 18 Oct 2012 10:31:15 +0900
parents 1cb51d65453d
children 66f0c78350ab
comparison
equal deleted inserted replaced
17836:98347af64593 17837:b623e323c561
3263 if not ui.verbose: 3263 if not ui.verbose:
3264 if not full: 3264 if not full:
3265 rst.append(_('\nuse "hg help %s" to show the full help text\n') 3265 rst.append(_('\nuse "hg help %s" to show the full help text\n')
3266 % name) 3266 % name)
3267 elif not ui.quiet: 3267 elif not ui.quiet:
3268 rst.append(_('\nuse "hg -v help %s" to show more info\n') 3268 omitted = _('use "hg -v help %s" to show more complete'
3269 % name) 3269 ' help and the global options') % name
3270 notomitted = _('use "hg -v help %s" to show'
3271 ' the global options') % name
3272 help.indicateomitted(rst, omitted, notomitted)
3273
3270 return rst 3274 return rst
3271 3275
3272 3276
3273 def helplist(select=None): 3277 def helplist(select=None):
3274 # list of commands 3278 # list of commands
3367 if not doc: 3371 if not doc:
3368 rst.append(" %s\n" % _("(no help text available)")) 3372 rst.append(" %s\n" % _("(no help text available)"))
3369 if util.safehasattr(doc, '__call__'): 3373 if util.safehasattr(doc, '__call__'):
3370 rst += [" %s\n" % l for l in doc().splitlines()] 3374 rst += [" %s\n" % l for l in doc().splitlines()]
3371 3375
3376 if not ui.verbose:
3377 omitted = (_('use "hg help -v %s" to show more complete help') %
3378 name)
3379 help.indicateomitted(rst, omitted)
3380
3372 try: 3381 try:
3373 cmdutil.findcmd(name, table) 3382 cmdutil.findcmd(name, table)
3374 rst.append(_('\nuse "hg help -c %s" to see help for ' 3383 rst.append(_('\nuse "hg help -c %s" to see help for '
3375 'the %s command\n') % (name, name)) 3384 'the %s command\n') % (name, name))
3376 except error.UnknownCommand: 3385 except error.UnknownCommand:
3393 head, tail = doc.split('\n', 1) 3402 head, tail = doc.split('\n', 1)
3394 rst = [_('%s extension - %s\n\n') % (name.split('.')[-1], head)] 3403 rst = [_('%s extension - %s\n\n') % (name.split('.')[-1], head)]
3395 if tail: 3404 if tail:
3396 rst.extend(tail.splitlines(True)) 3405 rst.extend(tail.splitlines(True))
3397 rst.append('\n') 3406 rst.append('\n')
3407
3408 if not ui.verbose:
3409 omitted = (_('use "hg help -v %s" to show more complete help') %
3410 name)
3411 help.indicateomitted(rst, omitted)
3398 3412
3399 if mod: 3413 if mod:
3400 try: 3414 try:
3401 ct = mod.cmdtable 3415 ct = mod.cmdtable
3402 except AttributeError: 3416 except AttributeError:
3457 if not ui.quiet: 3471 if not ui.quiet:
3458 rst = [_("Mercurial Distributed SCM\n"), '\n'] 3472 rst = [_("Mercurial Distributed SCM\n"), '\n']
3459 rst.extend(helplist()) 3473 rst.extend(helplist())
3460 3474
3461 keep = ui.verbose and ['verbose'] or [] 3475 keep = ui.verbose and ['verbose'] or []
3462 formatted, pruned = minirst.format(''.join(rst), textwidth, keep=keep) 3476 text = ''.join(rst)
3477 formatted, pruned = minirst.format(text, textwidth, keep=keep)
3478 if 'verbose' in pruned:
3479 keep.append('omitted')
3480 else:
3481 keep.append('notomitted')
3482 formatted, pruned = minirst.format(text, textwidth, keep=keep)
3463 ui.write(formatted) 3483 ui.write(formatted)
3464 3484
3465 3485
3466 @command('identify|id', 3486 @command('identify|id',
3467 [('r', 'rev', '', 3487 [('r', 'rev', '',