##// END OF EJS Templates
chmod: create a new file when flags are set on a hardlinked file...
Koen Van Hoof -
r32721:c2cb0de2 default
parent child Browse files
Show More
@@ -98,7 +98,8 b' def isexec(f):'
98 98 return (os.lstat(f).st_mode & 0o100 != 0)
99 99
100 100 def setflags(f, l, x):
101 s = os.lstat(f).st_mode
101 st = os.lstat(f)
102 s = st.st_mode
102 103 if l:
103 104 if not stat.S_ISLNK(s):
104 105 # switch file to link
@@ -125,6 +126,14 b' def setflags(f, l, x):'
125 126 s = 0o666 & ~umask # avoid restatting for chmod
126 127
127 128 sx = s & 0o100
129 if st.st_nlink > 1 and bool(x) != bool(sx):
130 # the file is a hardlink, break it
131 with open(f, "rb") as fp:
132 data = fp.read()
133 unlink(f)
134 with open(f, "wb") as fp:
135 fp.write(data)
136
128 137 if x and not sx:
129 138 # Turn on +x for every +r bit when making a file executable
130 139 # and obey umask.
@@ -203,10 +203,18 b' Committing a change to f1 in r1 must bre'
203 203 2 r2/.hg/store/fncache
204 204 #endif
205 205
206 Create a file which exec permissions we will change
207 $ cd r3
208 $ echo "echo hello world" > f3
209 $ hg add f3
210 $ hg ci -mf3
211 $ cd ..
212
206 213 $ cd r3
207 214 $ hg tip --template '{rev}:{node|short}\n'
208 11:a6451b6bc41f
215 12:d3b77733a28a
209 216 $ echo bla > f1
217 $ chmod +x f3
210 218 $ hg ci -m1
211 219 $ cd ..
212 220
@@ -241,6 +249,7 b' r4 has hardlinks in the working dir (not'
241 249 2 r4/.hg/store/data/d1/f2.d
242 250 2 r4/.hg/store/data/d1/f2.i
243 251 2 r4/.hg/store/data/f1.i
252 2 r4/.hg/store/data/f3.i
244 253 2 r4/.hg/store/fncache
245 254 2 r4/.hg/store/phaseroots
246 255 2 r4/.hg/store/undo
@@ -256,17 +265,18 b' r4 has hardlinks in the working dir (not'
256 265 2 r4/d1/data1
257 266 2 r4/d1/f2
258 267 2 r4/f1
268 2 r4/f3
259 269
270 Update back to revision 12 in r4 should break hardlink of file f1 and f3:
260 271 #if hardlink-whitelisted
261 272 $ nlinksdir r4/.hg/undo.backup.dirstate r4/.hg/undo.dirstate
262 273 4 r4/.hg/undo.backup.dirstate
263 274 4 r4/.hg/undo.dirstate
264 275 #endif
265 276
266 Update back to revision 11 in r4 should break hardlink of file f1:
267 277
268 $ hg -R r4 up 11
269 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
278 $ hg -R r4 up 12
279 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
270 280
271 281 $ nlinksdir r4
272 282 2 r4/.hg/00changelog.i
@@ -287,6 +297,7 b' Update back to revision 11 in r4 should '
287 297 2 r4/.hg/store/data/d1/f2.d
288 298 2 r4/.hg/store/data/d1/f2.i
289 299 2 r4/.hg/store/data/f1.i
300 2 r4/.hg/store/data/f3.i
290 301 2 r4/.hg/store/fncache
291 302 2 r4/.hg/store/phaseroots
292 303 2 r4/.hg/store/undo
@@ -302,6 +313,7 b' Update back to revision 11 in r4 should '
302 313 2 r4/d1/data1
303 314 2 r4/d1/f2
304 315 1 r4/f1
316 1 r4/f3
305 317
306 318 #if hardlink-whitelisted
307 319 $ nlinksdir r4/.hg/undo.backup.dirstate r4/.hg/undo.dirstate
General Comments 0
You need to be logged in to leave comments. Login now