largefiles: when setting/clearing x bit on largefiles, don't change other bits
authorMads Kiilerich <madski@unity3d.com>
Sat, 08 Oct 2016 00:59:40 +0200
changeset 30141 c01acee367ec
parent 30140 747e546c561f
child 30142 3dcaf1c4e90d
largefiles: when setting/clearing x bit on largefiles, don't change other bits It is only the X bit that it matters to copy from the standin to the largefile in the working directory. While it generally doesn't do any harm to copy the whole mode, it is also "wrong" to copy more than the X bit we care about. It can make a difference if someone should try to handle largefiles differently, such as marking them read-only. Thus, do similar to what utils.setflags does and set the X bit where there are R bits and obey umask.
hgext/largefiles/lfcommands.py
--- a/hgext/largefiles/lfcommands.py	Sun Oct 09 15:54:49 2016 +0200
+++ b/hgext/largefiles/lfcommands.py	Sat Oct 08 00:59:40 2016 +0200
@@ -515,9 +515,13 @@
             rellfile = lfile
             relstandin = lfutil.standin(lfile)
             if wvfs.exists(relstandin):
-                mode = wvfs.stat(relstandin).st_mode
-                if mode != wvfs.stat(rellfile).st_mode:
-                    wvfs.chmod(rellfile, mode)
+                standinexec = wvfs.stat(relstandin).st_mode & 0o100
+                st = wvfs.stat(rellfile).st_mode
+                if standinexec != st & 0o100:
+                    st &= ~0o111
+                    if standinexec:
+                        st |= (st >> 2) & 0o111 & ~util.umask
+                    wvfs.chmod(rellfile, st)
                     update1 = 1
 
             updated += update1