wwrite: simplify with util.set_flags
authorMatt Mackall <mpm@selenic.com>
Thu, 27 Dec 2007 22:27:47 -0600
changeset 5703 14789f30ac11
parent 5702 1b914de8d0ba
child 5704 5049bbf988e1
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
mercurial/localrepo.py
tests/test-ro-message
tests/test-ro-message.out
--- 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)
--- 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'
--- 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