]> thyrsus.com Git - src.git/commitdiff
Don't throw unhandled exceptions.
authorEric S. Raymond <esr@thyrsus.com>
Fri, 7 Nov 2014 21:17:28 +0000 (16:17 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Fri, 7 Nov 2014 21:17:28 +0000 (16:17 -0500)
src

diff --git a/src b/src
index 1e856c7e30bf3d3f70becd6241d01cc477410fca..295eefe54f897d3c9b08d6ce1bdbb15a26e5570d 100755 (executable)
--- a/src
+++ b/src
@@ -21,9 +21,6 @@ def rfc3339(t):
 def announce(msg):
     sys.stdout.write("src: " + msg + "\n")
 
-def complain(msg):
-    sys.stderr.write("src: " + msg + "\n")
-
 def croak(msg):
     sys.stderr.write("src: " + msg + "\n")
     sys.exit(1)
@@ -39,7 +36,7 @@ pseudotime = False
 repodir = ".src"
 
 def do_or_die(dcmd, legend=b"", loud=False):
-    "Either execute a command or raise a fatal exception."
+    "Either execute a command or die."
     if legend:
         legend = " "  + legend
     if debug == 0 and not loud:
@@ -51,11 +48,11 @@ def do_or_die(dcmd, legend=b"", loud=False):
     try:
         retcode = subprocess.call("(" + dcmd + ")" + mute, shell=True)
         if retcode < 0:
-            complain(b"child was terminated by signal %d." % -retcode)
+            croak(b"child was terminated by signal %d." % -retcode)
         elif retcode != 0:
-            complain(b"child returned %d." % retcode)
+            croak(b"child returned %d." % retcode)
     except (OSError, IOError) as e:
-        complain(b"execution of %s%s failed: %s" % (dcmd, legend, e))
+        croak(b"execution of %s%s failed: %s" % (dcmd, legend, e))
 
 class popen_or_die:
     "Read or write from a subordinate process."
@@ -77,14 +74,13 @@ class popen_or_die:
             self.fp = os.popen(self.command, self.mode)
             return self.fp
         except (OSError, IOError) as oe:
-            complain(b"execution of %s%s failed: %s" \
+            croak(b"execution of %s%s failed: %s" \
                                  % (self.command, self.legend, oe))
     def __exit__(self, extype, value, traceback_unused):
         if extype:
-            complain(b"fatal exception in popen_or_die.")
-            raise extype(value)
+            croak(b"fatal exception in popen_or_die.")
         if self.fp.close() is not None:
-            complain(b"%s%s returned error." % (self.command, self.legend))
+            croak(b"%s%s returned error." % (self.command, self.legend))
         return False
 
 def capture_or_die(command):
@@ -304,11 +300,11 @@ def init_method(*args):
         try:
             os.mkdir(repodir)
         except OSError:
-            complain("creation failed, check directory permissions.")
+            croak("creation failed, check directory permissions.")
     elif os.path.isdir(repodir):
-        complain("%s already exists." % repodir)
+        croak("%s already exists." % repodir)
     else:
-        complain("%s exists but is not a directory." % repodir)
+        croak("%s exists but is not a directory." % repodir)
 
 def preamble(cmd, args):
     "Common setup code."
@@ -365,9 +361,9 @@ def add_method(*args):
         croak("add doesn't take a revision spec")
     for arg in args:
        if not os.path.exists(arg):
-           complain("I see no '%s' here." % arg)
+           croak("I see no '%s' here." % arg)
        elif os.path.exists("%s/%s,v" % (repodir, arg)):
-           complain("%s is already registered." % arg)
+           croak("%s is already registered." % arg)
        else:
            do_or_die("rcs -q -kb -i {0} </dev/null && mv {0},v {1}".format(arg, repodir))
            announce("%s: 0" % arg) 
@@ -380,8 +376,6 @@ class lifted:
         do_or_die("mv {0}/{1},v .".format(repodir, self.name))
     def __exit__(self, extype, value, traceback_unused):
         do_or_die("mv {0},v {1}".format(self.name, repodir))
-        if extype:
-            raise extype(value)
         return True
 
 def commit_method(*args):