Show More
@@ -291,7 +291,7 b' def clone(ui, source, dest = None, **opt' | |||
|
291 | 291 | |
|
292 | 292 | if link: |
|
293 | 293 | ui.debug("copying by hardlink\n") |
|
294 |
|
|
|
294 | util.system("cp -al %s/.hg .hg" % source) | |
|
295 | 295 | try: |
|
296 | 296 | os.remove(".hg/dirstate") |
|
297 | 297 | except: pass |
@@ -871,6 +871,8 b' def dispatch(args):' | |||
|
871 | 871 | return r |
|
872 | 872 | else: |
|
873 | 873 | return d() |
|
874 | except util.CommandError, inst: | |
|
875 | u.warn("abort: %s\n" % inst.args) | |
|
874 | 876 | except hg.RepoError, inst: |
|
875 | 877 | u.warn("abort: ", inst, "!\n") |
|
876 | 878 | except SignalInterrupt: |
@@ -5,7 +5,7 b'' | |||
|
5 | 5 | # This software may be used and distributed according to the terms |
|
6 | 6 | # of the GNU General Public License, incorporated herein by reference. |
|
7 | 7 | |
|
8 | import os, sys, re, ConfigParser | |
|
8 | import os, sys, re, ConfigParser, util | |
|
9 | 9 | |
|
10 | 10 | class ui: |
|
11 | 11 | def __init__(self, verbose=False, debug=False, quiet=False, |
@@ -78,10 +78,7 b' class ui:' | |||
|
78 | 78 | f.close() |
|
79 | 79 | |
|
80 | 80 | editor = os.environ.get("HGEDITOR") or os.environ.get("EDITOR", "vi") |
|
81 |
|
|
|
82 | ||
|
83 | if r: | |
|
84 | raise "Edit failed!" | |
|
81 | util.system("%s %s" % (editor, name), errprefix = "edit failed") | |
|
85 | 82 | |
|
86 | 83 | t = open(name).read() |
|
87 | 84 | t = re.sub("(?m)^HG:.*\n", "", t) |
@@ -7,6 +7,29 b'' | |||
|
7 | 7 | |
|
8 | 8 | import os |
|
9 | 9 | |
|
10 | class CommandError(Exception): pass | |
|
11 | ||
|
12 | def explain_exit(code): | |
|
13 | """return a 2-tuple (desc, code) describing a process's status""" | |
|
14 | if os.WIFEXITED(code): | |
|
15 | val = os.WEXITSTATUS(code) | |
|
16 | return "exited with status %d" % val, val | |
|
17 | elif os.WIFSIGNALED(code): | |
|
18 | val = os.WTERMSIG(code) | |
|
19 | return "killed by signal %d" % val, val | |
|
20 | elif os.WIFSTOPPED(code): | |
|
21 | val = os.STOPSIG(code) | |
|
22 | return "stopped by signal %d" % val, val | |
|
23 | raise ValueError("invalid exit code") | |
|
24 | ||
|
25 | def system(cmd, errprefix = "abort"): | |
|
26 | """execute a shell command that must succeed""" | |
|
27 | rc = os.system(cmd) | |
|
28 | if rc: | |
|
29 | errmsg = "%s: %s %s" % (errprefix, os.path.basename(cmd.split(None, 1)[0]), | |
|
30 | explain_exit(rc)[0]) | |
|
31 | raise CommandError(errmsg) | |
|
32 | ||
|
10 | 33 | def rename(src, dst): |
|
11 | 34 | try: |
|
12 | 35 | os.rename(src, dst) |
General Comments 0
You need to be logged in to leave comments.
Login now