[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [Svnmerge] [PATCH] svnmerge.py: all error handling to be done using the error() function

From: Daniel Rall <dlr_at_collab.net>
Date: 2006-03-31 20:27:13 CEST

...
> --- contrib/client-side/svnmerge.py (revision 19109)
> +++ contrib/client-side/svnmerge.py (working copy)
> @@ -56,10 +56,14 @@
> import sys, os, getopt, re, types, popen2, tempfile
> from bisect import bisect
>
> +def error(s):
> + """Subroutine to output an error and bail."""
> + print >> sys.stderr, "%s: %s" % (NAME, s)
> + sys.exit(1)
> +

We don't really need to relocate the definition of this function
within the source file.

...
> @@ -1629,11 +1627,12 @@
> try:
> main(sys.argv[1:])
> except LaunchError, (ret, cmd, out):
> - print "%s: command execution failed (exit code: %d)" % (NAME, ret)
> - print cmd
> - print "".join(out)
> - sys.exit(1)
> + err_str = '%s: command execution failed ' % NAME

There's no reason to prepend NAME if we're using error(), since that
function handles the prepending for us.

> + err_str += '(exit code: %d)\n' % ret
> + err_str += cmd + '\n'
> + err_str += "".join(out)
> + error(err_str)
> except KeyboardInterrupt:
> # Avoid traceback on CTRL+C
> - print "aborted by user"
> - sys.exit(1)
> + err_str = "aborted by user"
> + error(err_str)

Is a control-c really an error? I'd certainly rather see this output
on stdout than stderr.

-- 
Daniel Rall

  • application/pgp-signature attachment: stored
Received on Fri Mar 31 20:27:38 2006

This is an archived mail posted to the Subversion Dev mailing list.