[PATCH 1 of 2] chgserver: add "setumask2" command which uses correct message frame
Yuya Nishihara
yuya at tcha.org
Fri Oct 5 13:30:36 UTC 2018
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1538663155 -32400
# Thu Oct 04 23:25:55 2018 +0900
# Node ID fea3ce7f43989d7fd50a04cf2f8ff402031cdbd8
# Parent 4fcbf5e3c74ec52e78026376b09d4cb4e7ff9783
chgserver: add "setumask2" command which uses correct message frame
The first 4 bytes should be a length field, not a value. Spotted while
porting chg functions to the Rust one.
diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py
--- a/mercurial/chgserver.py
+++ b/mercurial/chgserver.py
@@ -19,7 +19,8 @@
'setenv' command
replace os.environ completely
-'setumask' command
+'setumask' command (DEPRECATED)
+'setumask2' command
set umask
'validate' command
@@ -452,8 +453,20 @@ class chgcmdserver(commandserver.server)
os.chdir(path)
def setumask(self):
+ """Change umask (DEPRECATED)"""
+ # BUG: this does not follow the message frame structure, but kept for
+ # backward compatibility with old chg clients for some time
+ self._setumask(self._read(4))
+
+ def setumask2(self):
"""Change umask"""
- mask = struct.unpack('>I', self._read(4))[0]
+ data = self._readstr()
+ if len(data) != 4:
+ raise ValueError('invalid mask length in setumask2 request')
+ self._setumask(data)
+
+ def _setumask(self, data):
+ mask = struct.unpack('>I', data)[0]
_log('setumask %r\n' % mask)
os.umask(mask)
@@ -488,7 +501,8 @@ class chgcmdserver(commandserver.server)
'chdir': chdir,
'runcommand': runcommand,
'setenv': setenv,
- 'setumask': setumask})
+ 'setumask': setumask,
+ 'setumask2': setumask2})
if util.safehasattr(procutil, 'setprocname'):
def setprocname(self):
More information about the Mercurial-devel
mailing list