changeset 1969:6d17d420c46c

write_bundle: close the file before removing it in case of failure
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Fri, 17 Mar 2006 18:53:04 +0100
parents 37dd4928d042
children 119165543ce6
files mercurial/commands.py
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -297,8 +297,10 @@ def write_bundle(cg, filename, compress=
             fh.write(z.compress(chunk))
         fh.write(z.flush())
     except:
+        fh.close()
         os.unlink(filename)
         raise
+    fh.close()
 
 def dodiff(fp, ui, repo, node1, node2, files=None, match=util.always,
            changes=None, text=False, opts={}):
@@ -1790,7 +1792,6 @@ def incoming(ui, repo, source="default",
 
         cg = other.changegroup(incoming, "incoming")
         write_bundle(cg, fname, compress=other.local(), fh=f)
-        f.close()
         if not other.local():
             # use a bundlerepo
             other = bundlerepo.bundlerepository(ui, repo.root, fname)