diff mercurial/util.py @ 13112:039a964dbbb3

opener: always reset flags on 'w'rite only the patcher needs to preserve flags on write
author Adrian Buehlmann <adrian@cadifra.com>
date Fri, 10 Dec 2010 15:14:05 +0100
parents a08b49d2f116
children 873c032c81b5
line wrap: on
line diff
--- a/mercurial/util.py	Thu Dec 09 16:52:14 2010 -0500
+++ b/mercurial/util.py	Fri Dec 10 15:14:05 2010 +0100
@@ -882,7 +882,6 @@
             mode += "b" # for that other OS
 
         nlink = -1
-        st_mode = None
         dirname, basename = os.path.split(f)
         # If basename is empty, then the path is malformed because it points
         # to a directory. Let the posixfile() call below raise IOError.
@@ -893,7 +892,6 @@
                 return atomictempfile(f, mode, self.createmode)
             try:
                 if 'w' in mode:
-                    st_mode = os.lstat(f).st_mode & 0777
                     os.unlink(f)
                     nlink = 0
                 else:
@@ -913,10 +911,7 @@
                     rename(mktempcopy(f), f)
         fp = posixfile(f, mode)
         if nlink == 0:
-            if st_mode is None:
-                self._fixfilemode(f)
-            else:
-                os.chmod(f, st_mode)
+            self._fixfilemode(f)
         return fp
 
     def symlink(self, src, dst):