[PATCH 1 of 2] largefiles: clarify variable name holding file mode
Mads Kiilerich
mads at kiilerich.com
Wed Nov 2 15:25:26 UTC 2016
# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1476801939 -7200
# Tue Oct 18 16:45:39 2016 +0200
# Node ID 90300200bc1fcaedcc6ab109574d08b01ece2853
# Parent bb586966818986131068280bfd95fc96fbdaaa0d
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.
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
More information about the Mercurial-devel
mailing list