chgserver: update the umask cache before each run
authorPulkit Goyal <7895pulkit@gmail.com>
Tue, 31 Mar 2020 15:11:33 +0530
changeset 44629 d37975386798
parent 44628 4dacd0cef146
child 44630 4c6189d45d67
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.
mercurial/chgserver.py
mercurial/util.py
--- a/mercurial/chgserver.py	Thu Mar 26 10:09:17 2020 -0400
+++ b/mercurial/chgserver.py	Tue Mar 31 15:11:33 2020 +0530
@@ -528,7 +528,7 @@
     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
--- a/mercurial/util.py	Thu Mar 26 10:09:17 2020 -0400
+++ b/mercurial/util.py	Tue Mar 31 15:11:33 2020 +0530
@@ -130,6 +130,16 @@
 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