Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/util.py @ 521:0fb8ade0f756
[PATCH] Fix use of util.CommandError
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
[PATCH] Fix use of util.CommandError
From: Bryan O'Sullivan <bos@serpentine.com>
Fix CommandError so error messages don't say "abort: abort: ...".
manifest hash: 2aea4c8043d321882dcdf846a42a55403ce1086f
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCwvOZywK+sNU5EO8RAqF/AJ9IIr6JPPUc15tb7w4lnI7yMFxSmgCfQUYn
OX7Uz7G3dJNRIjAxJtGwCLo=
=xj/W
-----END PGP SIGNATURE-----
author | mpm@selenic.com |
---|---|
date | Wed, 29 Jun 2005 11:16:41 -0800 |
parents | 03f27b1381f9 |
children | f6c6fa15ff70 |
comparison
equal
deleted
inserted
replaced
520:12b4b5612fe4 | 521:0fb8ade0f756 |
---|---|
20 elif os.WIFSTOPPED(code): | 20 elif os.WIFSTOPPED(code): |
21 val = os.STOPSIG(code) | 21 val = os.STOPSIG(code) |
22 return "stopped by signal %d" % val, val | 22 return "stopped by signal %d" % val, val |
23 raise ValueError("invalid exit code") | 23 raise ValueError("invalid exit code") |
24 | 24 |
25 def system(cmd, errprefix = "abort"): | 25 def system(cmd, errprefix=None): |
26 """execute a shell command that must succeed""" | 26 """execute a shell command that must succeed""" |
27 rc = os.system(cmd) | 27 rc = os.system(cmd) |
28 if rc: | 28 if rc: |
29 errmsg = "%s: %s %s" % (errprefix, os.path.basename(cmd.split(None, 1)[0]), | 29 errmsg = "%s %s" % (os.path.basename(cmd.split(None, 1)[0]), |
30 explain_exit(rc)[0]) | 30 explain_exit(rc)[0]) |
31 if errprefix: | |
32 errmsg = "%s: %s" % (errprefix, errmsg) | |
31 raise CommandError(errmsg) | 33 raise CommandError(errmsg) |
32 | 34 |
33 def rename(src, dst): | 35 def rename(src, dst): |
34 try: | 36 try: |
35 os.rename(src, dst) | 37 os.rename(src, dst) |