Patchwork [1,of,3] largefiles: clarify variable name holding file mode

login
register
mail settings
Submitter Mads Kiilerich
Date Oct. 18, 2016, 3:19 p.m.
Message ID <6d4322a34c2a543665d7.1476803985@madski>
Download mbox | patch
Permalink /patch/17169/
State Accepted
Headers show

Comments

Mads Kiilerich - Oct. 18, 2016, 3:19 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1476801939 -7200
#      Tue Oct 18 16:45:39 2016 +0200
# Node ID 6d4322a34c2a543665d702fd10f38f1af6001715
# Parent  26089f5e3b51d0416b985ec78e7facdb3113aa48
largefiles: clarify variable name holding file mode

A follow-up to c01acee367ec.

'st' sounds like the whole stat result while 'mode' is a better name for the
actual file mode.

Patch

diff --git a/hgext/largefiles/lfcommands.py b/hgext/largefiles/lfcommands.py
--- a/hgext/largefiles/lfcommands.py
+++ b/hgext/largefiles/lfcommands.py
@@ -510,18 +510,21 @@  def updatelfiles(ui, repo, filelist=None
                 lfdirstate.normal(lfile)
                 update1 = 1
 
-            # copy the state of largefile standin from the repository's
+            # copy the exec mode of largefile standin from the repository's
             # dirstate to its state in the lfdirstate.
             rellfile = lfile
             relstandin = lfutil.standin(lfile)
             if wvfs.exists(relstandin):
+                # exec is decided by the users permissions using mask 0o100
                 standinexec = wvfs.stat(relstandin).st_mode & 0o100
-                st = wvfs.stat(rellfile).st_mode
-                if standinexec != st & 0o100:
-                    st &= ~0o111
+                st = wvfs.stat(rellfile)
+                mode = st.st_mode
+                if standinexec != mode & 0o100:
+                    # first remove all X bits, then shift all R bits to X
+                    mode &= ~0o111
                     if standinexec:
-                        st |= (st >> 2) & 0o111 & ~util.umask
-                    wvfs.chmod(rellfile, st)
+                        mode |= (mode >> 2) & 0o111 & ~util.umask
+                    wvfs.chmod(rellfile, mode)
                     update1 = 1
 
             updated += update1