Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 11524:24965bb270b7
dispatch: add shell aliases
This patch adds git-style "shell aliases" to Mercurial.
Any alias with a definition beginning with a '!' will be treated as a shell
alias. For example:
[alias]
echo = !echo
qempty = !hg qrefresh -X "`hg root`" ; echo Emptied patch "`hg qtop`"
$ hg echo foo
foo
$ hg qempty
Emptied patch foo
$
author | Steve Losh <steve@stevelosh.com> |
---|---|
date | Wed, 07 Jul 2010 18:49:43 -0400 |
parents | cc982ff2dcf8 |
children | f4eddec324b7 |
comparison
equal
deleted
inserted
replaced
11517:8bbe396883db | 11524:24965bb270b7 |
---|---|
1864 # description | 1864 # description |
1865 doc = gettext(entry[0].__doc__) | 1865 doc = gettext(entry[0].__doc__) |
1866 if not doc: | 1866 if not doc: |
1867 doc = _("(no help text available)") | 1867 doc = _("(no help text available)") |
1868 if hasattr(entry[0], 'definition'): # aliased command | 1868 if hasattr(entry[0], 'definition'): # aliased command |
1869 doc = _('alias for: hg %s\n\n%s') % (entry[0].definition, doc) | 1869 if entry[0].definition.startswith('!'): # shell alias |
1870 doc = _('shell alias for::\n\n %s') % entry[0].definition[1:] | |
1871 else: | |
1872 doc = _('alias for: hg %s\n\n%s') % (entry[0].definition, doc) | |
1870 if ui.quiet: | 1873 if ui.quiet: |
1871 doc = doc.splitlines()[0] | 1874 doc = doc.splitlines()[0] |
1872 keep = ui.verbose and ['verbose'] or [] | 1875 keep = ui.verbose and ['verbose'] or [] |
1873 formatted, pruned = minirst.format(doc, textwidth, keep=keep) | 1876 formatted, pruned = minirst.format(doc, textwidth, keep=keep) |
1874 ui.write("\n%s\n" % formatted) | 1877 ui.write("\n%s\n" % formatted) |