Mercurial > public > mercurial-scm > hg-stable
diff mercurial/commands.py @ 4561:a73d80d6385a
Revive commands.dispatch as a simple way to call hg from other pythons scripts.
This was already used by hg-ssh and others and is really convenient if you
just want a native equivalent of calling the command line version.
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Tue, 12 Jun 2007 17:39:57 +0200 |
parents | 0c61124ad877 |
children | 6a8e1dd18ba2 |
line wrap: on
line diff
--- a/mercurial/commands.py Mon Jun 11 21:09:24 2007 -0500 +++ b/mercurial/commands.py Tue Jun 12 17:39:57 2007 +0200 @@ -2997,11 +2997,13 @@ " debugindex debugindexdot debugdate debuginstall") optionalrepo = ("paths serve showconfig") -def run(): +def dispatch(args): try: - u = ui.ui(traceback='--traceback' in sys.argv[1:]) + u = ui.ui(traceback='--traceback' in args) except util.Abort, inst: sys.stderr.write(_("abort: %s\n") % inst) return -1 - sys.exit(cmdutil.runcatch(u, sys.argv[1:])) - + return cmdutil.runcatch(u, args) + +def run(): + sys.exit(dispatch(sys.argv[1:]))