[PATCH V2] chgserver: update the umask cache before each run

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH V2] chgserver: update the umask cache before each run

Pulkit Goyal
# HG changeset patch
# User Pulkit Goyal <[hidden email]>
# 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

_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH V2] chgserver: update the umask cache before each run

Yuya Nishihara
On Tue, 31 Mar 2020 22:41:50 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <[hidden email]>
> # 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

Queued, thanks.
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel