Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 508:42a660abaf75
[PATCH] Harden os.system
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
[PATCH] Harden os.system
From: Bryan O'Sullivan <bos@serpentine.com>
Add util.system function. This is similar to os.system, but will
either succeed (if the process finishes with a zero exit code) or raise
a util.CommandError (if the process exits uncleanly or is killed by
a signal).
Add util.explain_exit function. This tends to be ubiquitous in code
that calls other processes, and must describe what has gone wrong.
Change some uses of os.system over to util.system.
manifest hash: e3bf4adcac5b915432ec0af00efdbcef86bea4b1
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCwSipywK+sNU5EO8RAr0RAJkBDt8XQ7mYQAWNHNgTOVt1eyWU1QCfe1oO
2OwxyWqpbRNACVJHHfZ3/Xw=
=OaRX
-----END PGP SIGNATURE-----
author | mpm@selenic.com |
---|---|
date | Tue, 28 Jun 2005 02:38:33 -0800 |
parents | 1f81ebff98c9 |
children | 98a2935c3d6c |
comparison
equal
deleted
inserted
replaced
507:dd8b19114fe7 | 508:42a660abaf75 |
---|---|
289 | 289 |
290 os.chdir(dest) | 290 os.chdir(dest) |
291 | 291 |
292 if link: | 292 if link: |
293 ui.debug("copying by hardlink\n") | 293 ui.debug("copying by hardlink\n") |
294 os.system("cp -al %s/.hg .hg" % source) | 294 util.system("cp -al %s/.hg .hg" % source) |
295 try: | 295 try: |
296 os.remove(".hg/dirstate") | 296 os.remove(".hg/dirstate") |
297 except: pass | 297 except: pass |
298 | 298 |
299 repo = hg.repository(ui, ".") | 299 repo = hg.repository(ui, ".") |
869 stats.sort_stats('time', 'calls') | 869 stats.sort_stats('time', 'calls') |
870 stats.print_stats(40) | 870 stats.print_stats(40) |
871 return r | 871 return r |
872 else: | 872 else: |
873 return d() | 873 return d() |
874 except util.CommandError, inst: | |
875 u.warn("abort: %s\n" % inst.args) | |
874 except hg.RepoError, inst: | 876 except hg.RepoError, inst: |
875 u.warn("abort: ", inst, "!\n") | 877 u.warn("abort: ", inst, "!\n") |
876 except SignalInterrupt: | 878 except SignalInterrupt: |
877 u.warn("killed!\n") | 879 u.warn("killed!\n") |
878 except KeyboardInterrupt: | 880 except KeyboardInterrupt: |