changeset 10203:6e26e3c2083f stable

patch: explicitely close input patch files when leaving If applydiff() raises an exception, the opened patch file is kept alive in the exception context. If it is a temporary file (for instance supplied by import command with stdin input), Windows cannot clean it up.
author Patrick Mezard <pmezard@gmail.com>
date Sun, 03 Jan 2010 19:47:07 +0100
parents d2847c4523e8
children 3ca8f2ae5fee 8b5ca9b9b435
files mercurial/patch.py
diffstat 1 files changed, 2 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/patch.py	Sun Jan 03 17:26:39 2010 +0100
+++ b/mercurial/patch.py	Sun Jan 03 19:47:07 2010 +0100
@@ -1126,6 +1126,8 @@
     finally:
         if cwd:
             os.chdir(curdir)
+        if fp != patchobj:
+            fp.close()
     if ret < 0:
         raise PatchError
     return ret > 0