Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/chgserver.py @ 40109:e5fbdc3659fc
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.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 04 Oct 2018 23:25:55 +0900 |
parents | a9f56e4501c1 |
children | d1338b4e39d0 |
comparison
equal
deleted
inserted
replaced
40108:212a52d8e9d8 | 40109:e5fbdc3659fc |
---|---|
17 change current directory | 17 change current directory |
18 | 18 |
19 'setenv' command | 19 'setenv' command |
20 replace os.environ completely | 20 replace os.environ completely |
21 | 21 |
22 'setumask' command | 22 'setumask' command (DEPRECATED) |
23 'setumask2' command | |
23 set umask | 24 set umask |
24 | 25 |
25 'validate' command | 26 'validate' command |
26 reload the config and check if the server is up to date | 27 reload the config and check if the server is up to date |
27 | 28 |
450 return | 451 return |
451 _log('chdir to %r\n' % path) | 452 _log('chdir to %r\n' % path) |
452 os.chdir(path) | 453 os.chdir(path) |
453 | 454 |
454 def setumask(self): | 455 def setumask(self): |
456 """Change umask (DEPRECATED)""" | |
457 # BUG: this does not follow the message frame structure, but kept for | |
458 # backward compatibility with old chg clients for some time | |
459 self._setumask(self._read(4)) | |
460 | |
461 def setumask2(self): | |
455 """Change umask""" | 462 """Change umask""" |
456 mask = struct.unpack('>I', self._read(4))[0] | 463 data = self._readstr() |
464 if len(data) != 4: | |
465 raise ValueError('invalid mask length in setumask2 request') | |
466 self._setumask(data) | |
467 | |
468 def _setumask(self, data): | |
469 mask = struct.unpack('>I', data)[0] | |
457 _log('setumask %r\n' % mask) | 470 _log('setumask %r\n' % mask) |
458 os.umask(mask) | 471 os.umask(mask) |
459 | 472 |
460 def runcommand(self): | 473 def runcommand(self): |
461 # pager may be attached within the runcommand session, which should | 474 # pager may be attached within the runcommand session, which should |
486 capabilities = commandserver.server.capabilities.copy() | 499 capabilities = commandserver.server.capabilities.copy() |
487 capabilities.update({'attachio': attachio, | 500 capabilities.update({'attachio': attachio, |
488 'chdir': chdir, | 501 'chdir': chdir, |
489 'runcommand': runcommand, | 502 'runcommand': runcommand, |
490 'setenv': setenv, | 503 'setenv': setenv, |
491 'setumask': setumask}) | 504 'setumask': setumask, |
505 'setumask2': setumask2}) | |
492 | 506 |
493 if util.safehasattr(procutil, 'setprocname'): | 507 if util.safehasattr(procutil, 'setprocname'): |
494 def setprocname(self): | 508 def setprocname(self): |
495 """Change process title""" | 509 """Change process title""" |
496 name = self._readstr() | 510 name = self._readstr() |