From patchwork Tue Mar 31 17:11:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [V2] chgserver: update the umask cache before each run From: Pulkit Goyal <7895pulkit@gmail.com> X-Patchwork-Id: 45952 Message-Id: <08a36f69ba2ade20096e.1585674710@workspace> To: mercurial-devel@mercurial-scm.org Date: Tue, 31 Mar 2020 22:41:50 +0530 # HG changeset patch # User Pulkit Goyal <7895pulkit@gmail.com> # Date 1585647693 -19800 # Tue Mar 31 15:11:33 2020 +0530 # Node ID 08a36f69ba2ade20096ee882efa9c3e019032ea5 # Parent 588c91753fff6f10758a872b331b2f61e0413586 # EXP-Topic chg-test chgserver: update the umask cache before each run posix.py uses a global variable to store the umask value resulting in caching of it when using chg. We need to update it before each command run as the umask can change between commands. This fixes test-inherit-mode.t with chg. diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py --- a/mercurial/chgserver.py +++ b/mercurial/chgserver.py @@ -528,7 +528,7 @@ class chgcmdserver(commandserver.server) def _setumask(self, data): mask = struct.unpack(b'>I', data)[0] self.ui.log(b'chgserver', b'setumask %r\n', mask) - os.umask(mask) + util.setumask(mask) def runcommand(self): # pager may be attached within the runcommand session, which should diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -130,6 +130,16 @@ umask = platform.umask unlink = platform.unlink username = platform.username + +def setumask(val): + ''' updates the umask. used by chg server ''' + if pycompat.iswindows: + return + os.umask(val) + global umask + platform.umask = umask = val & 0o777 + + # small compat layer compengines = compression.compengines SERVERROLE = compression.SERVERROLE