[PATCH 2 of 2 V2] localrepo: remove unneeded os.unlink call in wwrite

Adrian Buehlmann adrian at cadifra.com
Fri Dec 10 09:18:55 CST 2010

# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1291993814 -3600
# Node ID bc13f59d0db496a05f2aa6a974461e733a6adfee
# Parent  8e81e7ca1d2e4e6fe6110497b4e08892abd6af6a
localrepo: remove unneeded os.unlink call in wwrite

The opener already unlinks the filename before 'w'riting, for both
the symlink and the normal file case. It also now resets the flags
for normal files on 'w'rite, which makes this os.unlink call completely

For Windows, removing this extra unlink call helps to avoid tripping
issue2524 (os.unlink followed by a write).

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -629,10 +629,6 @@ class localrepository(repo.repository):
     def wwrite(self, filename, data, flags):
         data = self._filter(self._decodefilterpats, filename, data)
-        try:
-            os.unlink(self.wjoin(filename))
-        except OSError:
-            pass
         if 'l' in flags:
             self.wopener.symlink(data, filename)

More information about the Mercurial-devel mailing list