comparison mercurial/util.py @ 3905:a8c0365b2ace

util.system: fix quoting on windows
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Sat, 16 Dec 2006 02:38:18 -0200
parents 8e907b86126b
children 1063a631cb8e e6d54283c090
comparison
equal deleted inserted replaced
3904:0dd07dd63db3 3905:a8c0365b2ace
499 oldenv = {} 499 oldenv = {}
500 for k in environ: 500 for k in environ:
501 oldenv[k] = os.environ.get(k) 501 oldenv[k] = os.environ.get(k)
502 if cwd is not None: 502 if cwd is not None:
503 oldcwd = os.getcwd() 503 oldcwd = os.getcwd()
504 origcmd = cmd
505 if os.name == 'nt':
506 cmd = '"%s"' % cmd
504 try: 507 try:
505 for k, v in environ.iteritems(): 508 for k, v in environ.iteritems():
506 os.environ[k] = py2shell(v) 509 os.environ[k] = py2shell(v)
507 if cwd is not None and oldcwd != cwd: 510 if cwd is not None and oldcwd != cwd:
508 os.chdir(cwd) 511 os.chdir(cwd)
509 rc = os.system(cmd) 512 rc = os.system(cmd)
510 if rc and onerr: 513 if rc and onerr:
511 errmsg = '%s %s' % (os.path.basename(cmd.split(None, 1)[0]), 514 errmsg = '%s %s' % (os.path.basename(origcmd.split(None, 1)[0]),
512 explain_exit(rc)[0]) 515 explain_exit(rc)[0])
513 if errprefix: 516 if errprefix:
514 errmsg = '%s: %s' % (errprefix, errmsg) 517 errmsg = '%s: %s' % (errprefix, errmsg)
515 try: 518 try:
516 onerr.warn(errmsg + '\n') 519 onerr.warn(errmsg + '\n')