Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/util.py @ 2601:00fc88b0b256
move most of tag code to localrepository class.
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Wed, 12 Jul 2006 08:59:20 -0700 |
parents | 0875cda033fd |
children | 6c5b1b5cc160 |
comparison
equal
deleted
inserted
replaced
2600:c4325f0a9b91 | 2601:00fc88b0b256 |
---|---|
376 run with environment maybe modified, maybe in different dir. | 376 run with environment maybe modified, maybe in different dir. |
377 | 377 |
378 if command fails and onerr is None, return status. if ui object, | 378 if command fails and onerr is None, return status. if ui object, |
379 print error message and return status, else raise onerr object as | 379 print error message and return status, else raise onerr object as |
380 exception.''' | 380 exception.''' |
381 def py2shell(val): | |
382 'convert python object into string that is useful to shell' | |
383 if val in (None, False): | |
384 return '0' | |
385 if val == True: | |
386 return '1' | |
387 return str(val) | |
381 oldenv = {} | 388 oldenv = {} |
382 for k in environ: | 389 for k in environ: |
383 oldenv[k] = os.environ.get(k) | 390 oldenv[k] = os.environ.get(k) |
384 if cwd is not None: | 391 if cwd is not None: |
385 oldcwd = os.getcwd() | 392 oldcwd = os.getcwd() |
386 try: | 393 try: |
387 for k, v in environ.iteritems(): | 394 for k, v in environ.iteritems(): |
388 os.environ[k] = str(v) | 395 os.environ[k] = py2shell(v) |
389 if cwd is not None and oldcwd != cwd: | 396 if cwd is not None and oldcwd != cwd: |
390 os.chdir(cwd) | 397 os.chdir(cwd) |
391 rc = os.system(cmd) | 398 rc = os.system(cmd) |
392 if rc and onerr: | 399 if rc and onerr: |
393 errmsg = '%s %s' % (os.path.basename(cmd.split(None, 1)[0]), | 400 errmsg = '%s %s' % (os.path.basename(cmd.split(None, 1)[0]), |