##// END OF EJS Templates
help: report source of aliases
timeless -
r28828:3640c170 default
parent child Browse files
Show More
@@ -379,7 +379,7 b' def aliasinterpolate(name, args, cmd):'
379 return r.sub(lambda x: replacemap[x.group()], cmd)
379 return r.sub(lambda x: replacemap[x.group()], cmd)
380
380
381 class cmdalias(object):
381 class cmdalias(object):
382 def __init__(self, name, definition, cmdtable):
382 def __init__(self, name, definition, cmdtable, source):
383 self.name = self.cmd = name
383 self.name = self.cmd = name
384 self.cmdname = ''
384 self.cmdname = ''
385 self.definition = definition
385 self.definition = definition
@@ -389,6 +389,7 b' class cmdalias(object):'
389 self.help = ''
389 self.help = ''
390 self.badalias = None
390 self.badalias = None
391 self.unknowncmd = False
391 self.unknowncmd = False
392 self.source = source
392
393
393 try:
394 try:
394 aliases, entry = cmdutil.findcmd(self.name, cmdtable)
395 aliases, entry = cmdutil.findcmd(self.name, cmdtable)
@@ -499,7 +500,8 b' def addaliases(ui, cmdtable):'
499 # may use extension commands. Aliases can also use other alias definitions,
500 # may use extension commands. Aliases can also use other alias definitions,
500 # but only if they have been defined prior to the current definition.
501 # but only if they have been defined prior to the current definition.
501 for alias, definition in ui.configitems('alias'):
502 for alias, definition in ui.configitems('alias'):
502 aliasdef = cmdalias(alias, definition, cmdtable)
503 source = ui.configsource('alias', alias)
504 aliasdef = cmdalias(alias, definition, cmdtable, source)
503
505
504 try:
506 try:
505 olddef = cmdtable[aliasdef.cmd][0]
507 olddef = cmdtable[aliasdef.cmd][0]
@@ -336,10 +336,13 b' def help_(ui, name, unknowncmd=False, fu'
336 if not doc:
336 if not doc:
337 doc = _("(no help text available)")
337 doc = _("(no help text available)")
338 if util.safehasattr(entry[0], 'definition'): # aliased command
338 if util.safehasattr(entry[0], 'definition'): # aliased command
339 source = entry[0].source
339 if entry[0].definition.startswith('!'): # shell alias
340 if entry[0].definition.startswith('!'): # shell alias
340 doc = _('shell alias for::\n\n %s') % entry[0].definition[1:]
341 doc = (_('shell alias for::\n\n %s\n\ndefined by: %s\n') %
342 (entry[0].definition[1:], source))
341 else:
343 else:
342 doc = _('alias for: hg %s\n\n%s') % (entry[0].definition, doc)
344 doc = (_('alias for: hg %s\n\n%s\n\ndefined by: %s\n') %
345 (entry[0].definition, doc, source))
343 doc = doc.splitlines(True)
346 doc = doc.splitlines(True)
344 if ui.quiet or not full:
347 if ui.quiet or not full:
345 rst.append(doc[0])
348 rst.append(doc[0])
@@ -673,10 +673,50 b' this is a section and erroring out weird'
673 > def nohelp(ui, *args, **kwargs):
673 > def nohelp(ui, *args, **kwargs):
674 > pass
674 > pass
675 >
675 >
676 > def uisetup(ui):
677 > ui.setconfig('alias', 'shellalias', '!echo hi', 'helpext')
678 > ui.setconfig('alias', 'hgalias', 'summary', 'helpext')
679 >
676 > EOF
680 > EOF
677 $ echo '[extensions]' >> $HGRCPATH
681 $ echo '[extensions]' >> $HGRCPATH
678 $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
682 $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
679
683
684 Test for aliases
685
686 $ hg help hgalias
687 hg hgalias [--remote]
688
689 alias for: hg summary
690
691 summarize working directory state
692
693 This generates a brief summary of the working directory state, including
694 parents, branch, commit status, phase and available updates.
695
696 With the --remote option, this will check the default paths for incoming
697 and outgoing changes. This can be time-consuming.
698
699 Returns 0 on success.
700
701 defined by: helpext
702
703 options:
704
705 --remote check for push and pull
706
707 (some details hidden, use --verbose to show complete help)
708
709 $ hg help shellalias
710 hg shellalias
711
712 shell alias for:
713
714 echo hi
715
716 defined by: helpext
717
718 (some details hidden, use --verbose to show complete help)
719
680 Test command with no help text
720 Test command with no help text
681
721
682 $ hg help nohelp
722 $ hg help nohelp
@@ -2064,6 +2104,13 b' Dish up an empty repo; serve it cold.'
2064 show help for a given topic or a help overview
2104 show help for a given topic or a help overview
2065 </td></tr>
2105 </td></tr>
2066 <tr><td>
2106 <tr><td>
2107 <a href="/help/hgalias">
2108 hgalias
2109 </a>
2110 </td><td>
2111 summarize working directory state
2112 </td></tr>
2113 <tr><td>
2067 <a href="/help/identify">
2114 <a href="/help/identify">
2068 identify
2115 identify
2069 </a>
2116 </a>
@@ -2155,6 +2202,13 b' Dish up an empty repo; serve it cold.'
2155 print the root (top) of the current working directory
2202 print the root (top) of the current working directory
2156 </td></tr>
2203 </td></tr>
2157 <tr><td>
2204 <tr><td>
2205 <a href="/help/shellalias">
2206 shellalias
2207 </a>
2208 </td><td>
2209 (no help text available)
2210 </td></tr>
2211 <tr><td>
2158 <a href="/help/tag">
2212 <a href="/help/tag">
2159 tag
2213 tag
2160 </a>
2214 </a>
General Comments 0
You need to be logged in to leave comments. Login now