diff mercurial/dispatch.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 6ee107782018
children c20c2c4c0c63
line wrap: on
line diff
--- a/mercurial/dispatch.py	Wed Jul 07 14:29:40 2010 +0200
+++ b/mercurial/dispatch.py	Wed Jul 07 18:49:43 2010 -0400
@@ -208,6 +208,13 @@
 
             return
 
+        if self.definition.startswith('!'):
+            def fn(ui, *args):
+                cmd = '%s %s' % (self.definition[1:], ' '.join(args))
+                return util.system(cmd)
+            self.fn = fn
+            return
+
         args = shlex.split(self.definition)
         cmd = args.pop(0)
         args = map(util.expandpath, args)