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

Daniel Rall dlr at collab.net
Fri Mar 31 10:27:13 PST 2006


...
> --- 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : /pipermail/svnmerge/attachments/20060331/8f00fd5d/attachment.pgp 


More information about the Svnmerge mailing list