changeset 5479:dd5ca84ed868

merge with crew-stable
author Thomas Arendsen Hein <thomas@intevation.de>
date Thu, 25 Oct 2007 21:37:20 +0200
parents f00ed7c5877b (current diff) bff41174563f (diff)
children 04f033a03b1d
files
diffstat 1 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -9,7 +9,7 @@
 from i18n import _
 from node import *
 import base85, cmdutil, mdiff, util, context, revlog, diffhelpers
-import cStringIO, email.Parser, os, popen2, re, sha
+import cStringIO, email.Parser, os, popen2, re, sha, errno
 import sys, tempfile, zlib
 
 class PatchError(Exception):
@@ -402,11 +402,13 @@ class patchfile:
             st = None
             try:
                 st = os.lstat(dest)
-                if st.st_nlink > 1:
-                    os.unlink(dest)
-            except: pass
+            except OSError, inst:
+                if inst.errno != errno.ENOENT:
+                    raise
+            if st and st.st_nlink > 1:
+                os.unlink(dest)
             fp = file(dest, 'wb')
-            if st:
+            if st and st.st_nlink > 1:
                 os.chmod(dest, st.st_mode)
             fp.writelines(self.lines)
             fp.close()