# HG changeset patch # User Matt Mackall # Date 1198816067 21600 # Node ID 14789f30ac11fa3493852b90e4690678e82be686 # Parent 1b914de8d0bac580fdba37d2ee3175c3127253e9 wwrite: simplify with util.set_flags - always attempt to delete the file (gets rid of read-only message) - always write as a normal file - use set_flags to convert to link or set exec diff -r 1b914de8d0ba -r 14789f30ac11 mercurial/localrepo.py --- a/mercurial/localrepo.py Thu Dec 27 22:27:45 2007 -0600 +++ b/mercurial/localrepo.py Thu Dec 27 22:27:47 2007 -0600 @@ -505,16 +505,12 @@ def wwrite(self, filename, data, flags): data = self._filter("decode", filename, data) - if "l" in flags: - self.wopener.symlink(data, filename) - else: - try: - if self._link(filename): - os.unlink(self.wjoin(filename)) - except OSError: - pass - self.wopener(filename, 'w').write(data) - util.set_exec(self.wjoin(filename), "x" in flags) + try: + os.unlink(self.wjoin(filename)) + except OSError: + pass + self.wopener(filename, 'w').write(data) + util.set_flags(self.wjoin(filename), flags) def wwritedata(self, filename, data): return self._filter("decode", filename, data) diff -r 1b914de8d0ba -r 14789f30ac11 tests/test-ro-message --- a/tests/test-ro-message Thu Dec 27 22:27:45 2007 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -#!/bin/sh -HG=hg -"$HG" init -mkdir b -echo 'Bouncy' >b/bouncy -echo 'tricycle' >b/vehicle -"$HG" add b/bouncy -"$HG" add b/vehicle -"$HG" commit -m 'Adding bouncy' -echo 'bouncy' >>b/bouncy -"$HG" commit -m 'Making it bouncier' -"$HG" update -C 0 -echo 'stationary' >>b/vehicle -"$HG" commit -m 'Clarifying the vehicle.' -"$HG" update -C 1 -chmod a-w b/vehicle -"$HG" merge 2 2>&1 | sed 's|^\(.*[ ]\).*/\([^/]*/[^/]*/[^/]*\)$|\1\2|g' diff -r 1b914de8d0ba -r 14789f30ac11 tests/test-ro-message.out --- a/tests/test-ro-message.out Thu Dec 27 22:27:45 2007 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -1 files updated, 0 files merged, 0 files removed, 0 files unresolved -2 files updated, 0 files merged, 0 files removed, 0 files unresolved -abort: Permission denied: test-ro-message/b/vehicle