[MERGE] Make cmd_branch check the destination before doing any I/O on the source.
Andrew Bennetts
andrew at canonical.com
Wed Jul 26 01:48:22 BST 2006
On Tue, Jul 25, 2006 at 01:48:31PM -0500, John Arbash Meinel wrote:
[...]
> The only thing it really means is that if we get an exception, and then
> delete_tree() also raises, it will hide the original exception.
> The only way I know around it is:
>
> except Exception, e:
> try:
> to_transport.delete_tree('.')
> except:
> raise e
> raise
>
> That will raise the original exception delete_tree() fails, though you
> lose the traceback. And if delete_tree() succeeds, it raises the
> original exception with the original traceback.
You can do slightly better with sys.exc_info():
except Exception, e:
exc_value, exc_type, exc_tb = sys.exc_info()
try:
to_transport.delete_tree('.')
except:
raise exc_value, exc_type, exc_tb
raise
This preserves the original exception, although the code is a bit uglier.
-Andrew.
More information about the bazaar
mailing list