Patchwork [4,of,5,V2] chgserver: add setumask method

login
register
mail settings
Submitter Jun Wu
Date Feb. 16, 2016, 7:50 p.m.
Message ID <0e71344230a9d312b22f.1455652225@x1c>
Download mbox | patch
Permalink /patch/13232/
State Accepted
Delegated to: Yuya Nishihara
Headers show

Comments

Jun Wu - Feb. 16, 2016, 7:50 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1455546497 0
#      Mon Feb 15 14:28:17 2016 +0000
# Node ID 0e71344230a9d312b22fcb4a08c8da7399cd07b2
# Parent  f66564e297d91c89e1422923a1360ac31a5e14d3
chgserver: add setumask method

Before this patch, the server won't inherit umask from the client, which
will fail test-inherit-mode.t. This patch provides a way for the client
to change umask of the server, similar to chdir and setenv.

Patch

diff --git a/hgext/chgserver.py b/hgext/chgserver.py
--- a/hgext/chgserver.py
+++ b/hgext/chgserver.py
@@ -289,6 +289,12 @@ 
         _log('chdir to %r\n' % path)
         os.chdir(path)
 
+    def setumask(self):
+        """Change umask"""
+        mask = struct.unpack('>I', self._read(4))[0]
+        _log('setumask %r\n' % mask)
+        os.umask(mask)
+
     def getpager(self):
         """Read cmdargs and write pager command to r-channel if enabled
 
@@ -341,7 +347,8 @@ 
     capabilities.update({'attachio': attachio,
                          'chdir': chdir,
                          'getpager': getpager,
-                         'setenv': setenv})
+                         'setenv': setenv,
+                         'setumask': setumask})
 
 # copied from mercurial/commandserver.py
 class _requesthandler(SocketServer.StreamRequestHandler):