diff -r 9ef0850b9b68 -r 05c7d75be925 mercurial/util.py --- a/mercurial/util.py Fri Mar 10 20:06:41 2006 +0100 +++ b/mercurial/util.py Fri Mar 10 22:24:19 2006 -0800 @@ -325,6 +325,29 @@ errmsg = "%s: %s" % (errprefix, errmsg) raise Abort(errmsg) +def esystem(cmd, environ={}, cwd=None): + '''enhanced shell command execution. + run with environment maybe modified, maybe in different dir.''' + oldenv = {} + for k in environ: + oldenv[k] = os.environ.get(k) + if cwd is not None: + oldcwd = os.getcwd() + try: + for k, v in environ.iteritems(): + os.environ[k] = str(v) + if cwd is not None and oldcwd != cwd: + os.chdir(cwd) + return os.system(cmd) + finally: + for k, v in oldenv.iteritems(): + if v is None: + del os.environ[k] + else: + os.environ[k] = v + if cwd is not None and oldcwd != cwd: + os.chdir(oldcwd) + def rename(src, dst): """forcibly rename a file""" try: