Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/patch.py @ 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 | 9a4034b630c4 |
children | 3ca8f2ae5fee 25e572394f5c |
comparison
equal
deleted
inserted
replaced
10201:d2847c4523e8 | 10203:6e26e3c2083f |
---|---|
1124 try: | 1124 try: |
1125 ret = applydiff(ui, fp, files, strip=strip, eol=eol) | 1125 ret = applydiff(ui, fp, files, strip=strip, eol=eol) |
1126 finally: | 1126 finally: |
1127 if cwd: | 1127 if cwd: |
1128 os.chdir(curdir) | 1128 os.chdir(curdir) |
1129 if fp != patchobj: | |
1130 fp.close() | |
1129 if ret < 0: | 1131 if ret < 0: |
1130 raise PatchError | 1132 raise PatchError |
1131 return ret > 0 | 1133 return ret > 0 |
1132 | 1134 |
1133 def patch(patchname, ui, strip=1, cwd=None, files=None, eolmode='strict'): | 1135 def patch(patchname, ui, strip=1, cwd=None, files=None, eolmode='strict'): |