Changeset View
Changeset View
Standalone View
Standalone View
mercurial/help.py
Show First 20 Lines • Show All 447 Lines • ▼ Show 20 Line(s) | def inserttweakrc(ui, topic, doc): | ||||
def sub(m): | def sub(m): | ||||
lines = [m.group(1) + s for s in repl.splitlines()] | lines = [m.group(1) + s for s in repl.splitlines()] | ||||
return '\n'.join(lines) | return '\n'.join(lines) | ||||
return re.sub(br'( *)%s' % re.escape(marker), sub, doc) | return re.sub(br'( *)%s' % re.escape(marker), sub, doc) | ||||
addtopichook('config', inserttweakrc) | addtopichook('config', inserttweakrc) | ||||
def help_(ui, commands, name, unknowncmd=False, full=True, subtopic=None, | def help_(ui, commands, name, unknowncmd=False, full=True, subtopic=None, | ||||
**opts): | fullname=None, **opts): | ||||
''' | ''' | ||||
Generate the help for 'name' as unformatted restructured text. If | Generate the help for 'name' as unformatted restructured text. If | ||||
'name' is None, describe the commands available. | 'name' is None, describe the commands available. | ||||
''' | ''' | ||||
opts = pycompat.byteskwargs(opts) | opts = pycompat.byteskwargs(opts) | ||||
def helpcmd(name, subtopic=None): | def helpcmd(name, subtopic=None): | ||||
▲ Show 20 Lines • Show All 344 Lines • ▼ Show 20 Line(s) | elif name and name != 'shortlist': | ||||
rst = f(name, subtopic) | rst = f(name, subtopic) | ||||
break | break | ||||
except error.UnknownCommand: | except error.UnknownCommand: | ||||
pass | pass | ||||
else: | else: | ||||
if unknowncmd: | if unknowncmd: | ||||
raise error.UnknownCommand(name) | raise error.UnknownCommand(name) | ||||
else: | else: | ||||
msg = _('no such help topic: %s') % name | if fullname: | ||||
hint = _("try 'hg help --keyword %s'") % name | formatname = fullname | ||||
else: | |||||
av6: Concatenating things is not the best option when it comes to i18n, but even if it were, I think… | |||||
Not Done ReplyFair enough, I agree just the subtopic is fine. ngoldbaum: Fair enough, I agree just the subtopic is fine. | |||||
formatname = name | |||||
if subtopic: | |||||
hintname = subtopic | |||||
else: | |||||
hintname = name | |||||
msg = _('no such help topic: %s') % formatname | |||||
hint = _("try 'hg help --keyword %s'") % hintname | |||||
raise error.Abort(msg, hint=hint) | raise error.Abort(msg, hint=hint) | ||||
else: | else: | ||||
# program name | # program name | ||||
if not ui.quiet: | if not ui.quiet: | ||||
rst = [_("Mercurial Distributed SCM\n"), '\n'] | rst = [_("Mercurial Distributed SCM\n"), '\n'] | ||||
rst.extend(helplist(None, **pycompat.strkwargs(opts))) | rst.extend(helplist(None, **pycompat.strkwargs(opts))) | ||||
return ''.join(rst) | return ''.join(rst) | ||||
Show All 18 Lines | if fullname is not None: | ||||
subtopic = nameparts.pop(0) | subtopic = nameparts.pop(0) | ||||
if nameparts: | if nameparts: | ||||
section = encoding.lower('.'.join(nameparts)) | section = encoding.lower('.'.join(nameparts)) | ||||
textwidth = ui.configint('ui', 'textwidth') | textwidth = ui.configint('ui', 'textwidth') | ||||
termwidth = ui.termwidth() - 2 | termwidth = ui.termwidth() - 2 | ||||
if textwidth <= 0 or termwidth < textwidth: | if textwidth <= 0 or termwidth < textwidth: | ||||
textwidth = termwidth | textwidth = termwidth | ||||
text = help_(ui, commands, name, | text = help_(ui, commands, name, fullname=fullname, | ||||
subtopic=subtopic, unknowncmd=unknowncmd, full=full, **opts) | subtopic=subtopic, unknowncmd=unknowncmd, full=full, **opts) | ||||
blocks, pruned = minirst.parse(text, keep=keep) | blocks, pruned = minirst.parse(text, keep=keep) | ||||
if 'verbose' in pruned: | if 'verbose' in pruned: | ||||
keep.append('omitted') | keep.append('omitted') | ||||
else: | else: | ||||
keep.append('notomitted') | keep.append('notomitted') | ||||
blocks, pruned = minirst.parse(text, keep=keep) | blocks, pruned = minirst.parse(text, keep=keep) | ||||
Show All 10 Lines |
Concatenating things is not the best option when it comes to i18n, but even if it were, I think it would make sense to only show here the subtopic, if it's provided. If people are curious about internals.foobar (or config.foobar), then hg help -k foobar helps way more than hg help -k internals. And we already make sure that the topic that comes before the dot exists, right?