Mercurial > public > mercurial-scm > hg
comparison mercurial/util.py @ 8534:22ec9cf4d0ce
util: use "is" for True/False/None comparisons
author | Martin Geisler <mg@lazybytes.net> |
---|---|
date | Wed, 20 May 2009 10:50:23 +0200 |
parents | 8e2c0ab94432 |
children | 744d6322b05b |
comparison
equal
deleted
inserted
replaced
8533:6062c6362b2e | 8534:22ec9cf4d0ce |
---|---|
520 if command fails and onerr is None, return status. if ui object, | 520 if command fails and onerr is None, return status. if ui object, |
521 print error message and return status, else raise onerr object as | 521 print error message and return status, else raise onerr object as |
522 exception.''' | 522 exception.''' |
523 def py2shell(val): | 523 def py2shell(val): |
524 'convert python object into string that is useful to shell' | 524 'convert python object into string that is useful to shell' |
525 if val in (None, False): | 525 if val is None or val is False: |
526 return '0' | 526 return '0' |
527 if val == True: | 527 if val is True: |
528 return '1' | 528 return '1' |
529 return str(val) | 529 return str(val) |
530 oldenv = {} | 530 oldenv = {} |
531 for k in environ: | 531 for k in environ: |
532 oldenv[k] = os.environ.get(k) | 532 oldenv[k] = os.environ.get(k) |