Show More
@@ -37,6 +37,7 b' from . import (' | |||||
37 | hook, |
|
37 | hook, | |
38 | profiling, |
|
38 | profiling, | |
39 | pycompat, |
|
39 | pycompat, | |
|
40 | registrar, | |||
40 | scmutil, |
|
41 | scmutil, | |
41 | ui as uimod, |
|
42 | ui as uimod, | |
42 | util, |
|
43 | util, | |
@@ -503,6 +504,7 b' class cmdalias(object):' | |||||
503 | return ui.system(cmd, environ=env, |
|
504 | return ui.system(cmd, environ=env, | |
504 | blockedtag='alias_%s' % self.name) |
|
505 | blockedtag='alias_%s' % self.name) | |
505 | self.fn = fn |
|
506 | self.fn = fn | |
|
507 | self.alias = True | |||
506 | self._populatehelp(ui, name, shdef, self.fn) |
|
508 | self._populatehelp(ui, name, shdef, self.fn) | |
507 | return |
|
509 | return | |
508 |
|
510 | |||
@@ -530,6 +532,7 b' class cmdalias(object):' | |||||
530 | self.fn, self.opts = tableentry |
|
532 | self.fn, self.opts = tableentry | |
531 | cmdhelp = None |
|
533 | cmdhelp = None | |
532 |
|
534 | |||
|
535 | self.alias = True | |||
533 | self._populatehelp(ui, name, cmd, self.fn, cmdhelp) |
|
536 | self._populatehelp(ui, name, cmd, self.fn, cmdhelp) | |
534 |
|
537 | |||
535 | except error.UnknownCommand: |
|
538 | except error.UnknownCommand: | |
@@ -543,7 +546,7 b' class cmdalias(object):' | |||||
543 | def _populatehelp(self, ui, name, cmd, fn, defaulthelp=None): |
|
546 | def _populatehelp(self, ui, name, cmd, fn, defaulthelp=None): | |
544 | # confine strings to be passed to i18n.gettext() |
|
547 | # confine strings to be passed to i18n.gettext() | |
545 | cfg = {} |
|
548 | cfg = {} | |
546 | for k in ('doc', 'help'): |
|
549 | for k in ('doc', 'help', 'category'): | |
547 | v = ui.config('alias', '%s:%s' % (name, k), None) |
|
550 | v = ui.config('alias', '%s:%s' % (name, k), None) | |
548 | if v is None: |
|
551 | if v is None: | |
549 | continue |
|
552 | continue | |
@@ -558,11 +561,14 b' class cmdalias(object):' | |||||
558 | # drop prefix in old-style help lines so hg shows the alias |
|
561 | # drop prefix in old-style help lines so hg shows the alias | |
559 | self.help = self.help[4 + len(cmd):] |
|
562 | self.help = self.help[4 + len(cmd):] | |
560 |
|
563 | |||
|
564 | self.owndoc = 'doc' in cfg | |||
561 | doc = cfg.get('doc', pycompat.getdoc(fn)) |
|
565 | doc = cfg.get('doc', pycompat.getdoc(fn)) | |
562 | if doc is not None: |
|
566 | if doc is not None: | |
563 | doc = pycompat.sysstr(doc) |
|
567 | doc = pycompat.sysstr(doc) | |
564 | self.__doc__ = doc |
|
568 | self.__doc__ = doc | |
565 |
|
569 | |||
|
570 | self.helpcategory = cfg.get('category', registrar.command.CATEGORY_NONE) | |||
|
571 | ||||
566 | @property |
|
572 | @property | |
567 | def args(self): |
|
573 | def args(self): | |
568 | args = pycompat.maplist(util.expandpath, self.givenargs) |
|
574 | args = pycompat.maplist(util.expandpath, self.givenargs) | |
@@ -613,6 +619,7 b' class lazyaliasentry(object):' | |||||
613 | self.definition = definition |
|
619 | self.definition = definition | |
614 | self.cmdtable = cmdtable.copy() |
|
620 | self.cmdtable = cmdtable.copy() | |
615 | self.source = source |
|
621 | self.source = source | |
|
622 | self.alias = True | |||
616 |
|
623 | |||
617 | @util.propertycache |
|
624 | @util.propertycache | |
618 | def _aliasdef(self): |
|
625 | def _aliasdef(self): |
@@ -189,12 +189,25 b' def indicateomitted(rst, omitted, notomi' | |||||
189 | if notomitted: |
|
189 | if notomitted: | |
190 | rst.append('\n\n.. container:: notomitted\n\n %s\n\n' % notomitted) |
|
190 | rst.append('\n\n.. container:: notomitted\n\n %s\n\n' % notomitted) | |
191 |
|
191 | |||
192 | def filtercmd(ui, cmd, kw, doc): |
|
192 | def filtercmd(ui, cmd, func, kw, doc): | |
193 | if not ui.debugflag and cmd.startswith("debug") and kw != "debug": |
|
193 | if not ui.debugflag and cmd.startswith("debug") and kw != "debug": | |
|
194 | # Debug command, and user is not looking for those. | |||
194 | return True |
|
195 | return True | |
195 | if not ui.verbose and doc and any(w in doc for w in _exclkeywords): |
|
196 | if not ui.verbose: | |
|
197 | if not kw and not doc: | |||
|
198 | # Command had no documentation, no point in showing it by default. | |||
|
199 | return True | |||
|
200 | if getattr(func, 'alias', False) and not getattr(func, 'owndoc', False): | |||
|
201 | # Alias didn't have its own documentation. | |||
|
202 | return True | |||
|
203 | if doc and any(w in doc for w in _exclkeywords): | |||
|
204 | # Documentation has excluded keywords. | |||
|
205 | return True | |||
|
206 | if kw == "shortlist" and not getattr(func, 'helpbasic', False): | |||
|
207 | # We're presenting the short list but the command is not basic. | |||
196 | return True |
|
208 | return True | |
197 | if ui.configbool('help', 'hidden-command.%s' % cmd): |
|
209 | if ui.configbool('help', 'hidden-command.%s' % cmd): | |
|
210 | # Configuration explicitly hides the command. | |||
198 | return True |
|
211 | return True | |
199 | return False |
|
212 | return False | |
200 |
|
213 | |||
@@ -230,13 +243,14 b' def topicmatch(ui, commands, kw):' | |||||
230 | else: |
|
243 | else: | |
231 | summary = '' |
|
244 | summary = '' | |
232 | # translate docs *before* searching there |
|
245 | # translate docs *before* searching there | |
233 | docs = _(pycompat.getdoc(entry[0])) or '' |
|
246 | func = entry[0] | |
|
247 | docs = _(pycompat.getdoc(func)) or '' | |||
234 | if kw in cmd or lowercontains(summary) or lowercontains(docs): |
|
248 | if kw in cmd or lowercontains(summary) or lowercontains(docs): | |
235 | doclines = docs.splitlines() |
|
249 | doclines = docs.splitlines() | |
236 | if doclines: |
|
250 | if doclines: | |
237 | summary = doclines[0] |
|
251 | summary = doclines[0] | |
238 | cmdname = cmdutil.parsealiases(cmd)[0] |
|
252 | cmdname = cmdutil.parsealiases(cmd)[0] | |
239 | if filtercmd(ui, cmdname, kw, docs): |
|
253 | if filtercmd(ui, cmdname, func, kw, docs): | |
240 | continue |
|
254 | continue | |
241 | results['commands'].append((cmdname, summary)) |
|
255 | results['commands'].append((cmdname, summary)) | |
242 | for name, docs in itertools.chain( |
|
256 | for name, docs in itertools.chain( | |
@@ -256,12 +270,13 b' def topicmatch(ui, commands, kw):' | |||||
256 | for cmd, entry in getattr(mod, 'cmdtable', {}).iteritems(): |
|
270 | for cmd, entry in getattr(mod, 'cmdtable', {}).iteritems(): | |
257 | if kw in cmd or (len(entry) > 2 and lowercontains(entry[2])): |
|
271 | if kw in cmd or (len(entry) > 2 and lowercontains(entry[2])): | |
258 | cmdname = cmdutil.parsealiases(cmd)[0] |
|
272 | cmdname = cmdutil.parsealiases(cmd)[0] | |
259 |
|
|
273 | func = entry[0] | |
|
274 | cmddoc = pycompat.getdoc(func) | |||
260 | if cmddoc: |
|
275 | if cmddoc: | |
261 | cmddoc = gettext(cmddoc).splitlines()[0] |
|
276 | cmddoc = gettext(cmddoc).splitlines()[0] | |
262 | else: |
|
277 | else: | |
263 | cmddoc = _('(no help text available)') |
|
278 | cmddoc = _('(no help text available)') | |
264 | if filtercmd(ui, cmdname, kw, cmddoc): |
|
279 | if filtercmd(ui, cmdname, func, kw, cmddoc): | |
265 | continue |
|
280 | continue | |
266 | results['extensioncommands'].append((cmdname, cmddoc)) |
|
281 | results['extensioncommands'].append((cmdname, cmddoc)) | |
267 | return results |
|
282 | return results | |
@@ -525,14 +540,17 b' def help_(ui, commands, name, unknowncmd' | |||||
525 | func = e[0] |
|
540 | func = e[0] | |
526 | if select and not select(f): |
|
541 | if select and not select(f): | |
527 | continue |
|
542 | continue | |
|
543 | # Only list built-in commands (defined in commands.py) and aliases | |||
|
544 | # (defined in dispatch.py), but not any other extensions. | |||
|
545 | # We don't want a circular dependency between this file and | |||
|
546 | # dispatch, so reference that by name. | |||
|
547 | # TODO(rdamazio): Just show commands from all extensions. | |||
528 | if (not select and name != 'shortlist' and |
|
548 | if (not select and name != 'shortlist' and | |
529 |
func.__module__ != commands.__name__ |
|
549 | func.__module__ != commands.__name__ and | |
|
550 | func.__module__ != 'mercurial.dispatch'): | |||
530 | continue |
|
551 | continue | |
531 | if name == "shortlist": |
|
|||
532 | if not getattr(func, 'helpbasic', False): |
|
|||
533 | continue |
|
|||
534 | doc = pycompat.getdoc(func) |
|
552 | doc = pycompat.getdoc(func) | |
535 | if filtercmd(ui, f, name, doc): |
|
553 | if filtercmd(ui, f, func, name, doc): | |
536 | continue |
|
554 | continue | |
537 | doc = gettext(doc) |
|
555 | doc = gettext(doc) | |
538 | if not doc: |
|
556 | if not doc: |
@@ -169,6 +169,10 b' class command(_funcregistrarbase):' | |||||
169 | """ |
|
169 | """ | |
170 |
|
170 | |||
171 | # Command categories for grouping them in help output. |
|
171 | # Command categories for grouping them in help output. | |
|
172 | # These can also be specified for aliases, like: | |||
|
173 | # [alias] | |||
|
174 | # myalias = something | |||
|
175 | # myalias:category = repo | |||
172 | CATEGORY_REPO_CREATION = 'repo' |
|
176 | CATEGORY_REPO_CREATION = 'repo' | |
173 | CATEGORY_REMOTE_REPO_MANAGEMENT = 'remote' |
|
177 | CATEGORY_REMOTE_REPO_MANAGEMENT = 'remote' | |
174 | CATEGORY_COMMITTING = 'commit' |
|
178 | CATEGORY_COMMITTING = 'commit' |
@@ -68,17 +68,17 b' basic' | |||||
68 | help |
|
68 | help | |
69 |
|
69 | |||
70 | $ hg help -c | grep myinit |
|
70 | $ hg help -c | grep myinit | |
71 |
myinit |
|
71 | myinit This is my documented alias for init. | |
72 | $ hg help -c | grep mycommit |
|
72 | $ hg help -c | grep mycommit | |
73 |
mycommit |
|
73 | mycommit This is my alias with only doc. | |
74 | $ hg help -c | grep cleanstatus |
|
74 | $ hg help -c | grep cleanstatus | |
75 | cleanstatus show changed files in the working directory |
|
75 | [1] | |
76 | $ hg help -c | grep lognull |
|
76 | $ hg help -c | grep lognull | |
77 |
lognull |
|
77 | lognull Logs the null rev | |
78 | $ hg help -c | grep dln |
|
78 | $ hg help -c | grep dln | |
79 | dln Logs the null rev |
|
79 | [1] | |
80 | $ hg help -c | grep recursivedoc |
|
80 | $ hg help -c | grep recursivedoc | |
81 |
recursivedoc |
|
81 | recursivedoc Logs the null rev in debug mode | |
82 | $ hg help myinit |
|
82 | $ hg help myinit | |
83 | hg myinit [OPTIONS] [BLA] [BLE] |
|
83 | hg myinit [OPTIONS] [BLA] [BLE] | |
84 |
|
84 | |||
@@ -602,7 +602,7 b' command provided extension, should be ab' | |||||
602 | help for a shell alias |
|
602 | help for a shell alias | |
603 |
|
603 | |||
604 | $ hg help -c | grep rebate |
|
604 | $ hg help -c | grep rebate | |
605 |
rebate |
|
605 | rebate This is my alias which just prints something. | |
606 | $ hg help rebate |
|
606 | $ hg help rebate | |
607 | hg rebate [MYARGS] |
|
607 | hg rebate [MYARGS] | |
608 |
|
608 |
@@ -823,6 +823,9 b' this is a section and erroring out weird' | |||||
823 | > def uisetup(ui): |
|
823 | > def uisetup(ui): | |
824 | > ui.setconfig(b'alias', b'shellalias', b'!echo hi', b'helpext') |
|
824 | > ui.setconfig(b'alias', b'shellalias', b'!echo hi', b'helpext') | |
825 | > ui.setconfig(b'alias', b'hgalias', b'summary', b'helpext') |
|
825 | > ui.setconfig(b'alias', b'hgalias', b'summary', b'helpext') | |
|
826 | > ui.setconfig(b'alias', b'hgalias:doc', b'My doc', b'helpext') | |||
|
827 | > ui.setconfig(b'alias', b'hgalias:category', b'navigation', b'helpext') | |||
|
828 | > ui.setconfig(b'alias', b'hgaliasnodoc', b'summary', b'helpext') | |||
826 | > |
|
829 | > | |
827 | > EOF |
|
830 | > EOF | |
828 | $ echo '[extensions]' >> $HGRCPATH |
|
831 | $ echo '[extensions]' >> $HGRCPATH | |
@@ -830,11 +833,28 b' this is a section and erroring out weird' | |||||
830 |
|
833 | |||
831 | Test for aliases |
|
834 | Test for aliases | |
832 |
|
835 | |||
|
836 | $ hg help | grep hgalias | |||
|
837 | hgalias My doc | |||
|
838 | ||||
833 | $ hg help hgalias |
|
839 | $ hg help hgalias | |
834 | hg hgalias [--remote] |
|
840 | hg hgalias [--remote] | |
835 |
|
841 | |||
836 | alias for: hg summary |
|
842 | alias for: hg summary | |
837 |
|
843 | |||
|
844 | My doc | |||
|
845 | ||||
|
846 | defined by: helpext | |||
|
847 | ||||
|
848 | options: | |||
|
849 | ||||
|
850 | --remote check for push and pull | |||
|
851 | ||||
|
852 | (some details hidden, use --verbose to show complete help) | |||
|
853 | $ hg help hgaliasnodoc | |||
|
854 | hg hgaliasnodoc [--remote] | |||
|
855 | ||||
|
856 | alias for: hg summary | |||
|
857 | ||||
838 | summarize working directory state |
|
858 | summarize working directory state | |
839 |
|
859 | |||
840 | This generates a brief summary of the working directory state, including |
|
860 | This generates a brief summary of the working directory state, including | |
@@ -947,6 +967,7 b' Test that default list of commands omits' | |||||
947 |
|
967 | |||
948 | bisect subdivision search of changesets |
|
968 | bisect subdivision search of changesets | |
949 | heads show branch heads |
|
969 | heads show branch heads | |
|
970 | hgalias My doc | |||
950 | identify identify the working directory or specified revision |
|
971 | identify identify the working directory or specified revision | |
951 | log show revision history of entire repository or files |
|
972 | log show revision history of entire repository or files | |
952 |
|
973 | |||
@@ -2662,6 +2683,13 b' Dish up an empty repo; serve it cold.' | |||||
2662 | hgalias |
|
2683 | hgalias | |
2663 | </a> |
|
2684 | </a> | |
2664 | </td><td> |
|
2685 | </td><td> | |
|
2686 | My doc | |||
|
2687 | </td></tr> | |||
|
2688 | <tr><td> | |||
|
2689 | <a href="/help/hgaliasnodoc"> | |||
|
2690 | hgaliasnodoc | |||
|
2691 | </a> | |||
|
2692 | </td><td> | |||
2665 | summarize working directory state |
|
2693 | summarize working directory state | |
2666 | </td></tr> |
|
2694 | </td></tr> | |
2667 | <tr><td> |
|
2695 | <tr><td> |
General Comments 0
You need to be logged in to leave comments.
Login now