169 mtimepaths = _getmtimepaths(ui) |
164 mtimepaths = _getmtimepaths(ui) |
170 confighash = _confighash(ui) |
165 confighash = _confighash(ui) |
171 mtimehash = _mtimehash(mtimepaths) |
166 mtimehash = _mtimehash(mtimepaths) |
172 _log('confighash = %s mtimehash = %s\n' % (confighash, mtimehash)) |
167 _log('confighash = %s mtimehash = %s\n' % (confighash, mtimehash)) |
173 return hashstate(confighash, mtimehash, mtimepaths) |
168 return hashstate(confighash, mtimehash, mtimepaths) |
174 |
|
175 # copied from hgext/pager.py:uisetup() |
|
176 def _setuppagercmd(ui, options, cmd): |
|
177 from . import commands # avoid cycle |
|
178 |
|
179 if not ui.formatted(): |
|
180 return |
|
181 |
|
182 p = ui.config("pager", "pager", encoding.environ.get("PAGER")) |
|
183 usepager = False |
|
184 always = util.parsebool(options['pager']) |
|
185 auto = options['pager'] == 'auto' |
|
186 |
|
187 if not p: |
|
188 pass |
|
189 elif always: |
|
190 usepager = True |
|
191 elif not auto: |
|
192 usepager = False |
|
193 else: |
|
194 attended = ['annotate', 'cat', 'diff', 'export', 'glog', 'log', 'qdiff'] |
|
195 attend = ui.configlist('pager', 'attend', attended) |
|
196 ignore = ui.configlist('pager', 'ignore') |
|
197 cmds, _ = cmdutil.findcmd(cmd, commands.table) |
|
198 |
|
199 for cmd in cmds: |
|
200 var = 'attend-%s' % cmd |
|
201 if ui.config('pager', var): |
|
202 usepager = ui.configbool('pager', var) |
|
203 break |
|
204 if (cmd in attend or |
|
205 (cmd not in ignore and not attend)): |
|
206 usepager = True |
|
207 break |
|
208 |
|
209 if usepager: |
|
210 ui.setconfig('ui', 'formatted', ui.formatted(), 'pager') |
|
211 ui.setconfig('ui', 'interactive', False, 'pager') |
|
212 return p |
|
213 |
169 |
214 def _newchgui(srcui, csystem, attachio): |
170 def _newchgui(srcui, csystem, attachio): |
215 class chgui(srcui.__class__): |
171 class chgui(srcui.__class__): |
216 def __init__(self, src=None): |
172 def __init__(self, src=None): |
217 super(chgui, self).__init__(src) |
173 super(chgui, self).__init__(src) |
482 """Change umask""" |
438 """Change umask""" |
483 mask = struct.unpack('>I', self._read(4))[0] |
439 mask = struct.unpack('>I', self._read(4))[0] |
484 _log('setumask %r\n' % mask) |
440 _log('setumask %r\n' % mask) |
485 os.umask(mask) |
441 os.umask(mask) |
486 |
442 |
487 def getpager(self): |
|
488 """Read cmdargs and write pager command to r-channel if enabled |
|
489 |
|
490 If pager isn't enabled, this writes '\0' because channeledoutput |
|
491 does not allow to write empty data. |
|
492 """ |
|
493 from . import dispatch # avoid cycle |
|
494 |
|
495 args = self._readlist() |
|
496 try: |
|
497 cmd, _func, args, options, _cmdoptions = dispatch._parse(self.ui, |
|
498 args) |
|
499 except (error.Abort, error.AmbiguousCommand, error.CommandError, |
|
500 error.UnknownCommand): |
|
501 cmd = None |
|
502 options = {} |
|
503 if not cmd or 'pager' not in options: |
|
504 self.cresult.write('\0') |
|
505 return |
|
506 |
|
507 pagercmd = _setuppagercmd(self.ui, options, cmd) |
|
508 if pagercmd: |
|
509 # Python's SIGPIPE is SIG_IGN by default. change to SIG_DFL so |
|
510 # we can exit if the pipe to the pager is closed |
|
511 if util.safehasattr(signal, 'SIGPIPE') and \ |
|
512 signal.getsignal(signal.SIGPIPE) == signal.SIG_IGN: |
|
513 signal.signal(signal.SIGPIPE, signal.SIG_DFL) |
|
514 self.cresult.write(pagercmd) |
|
515 else: |
|
516 self.cresult.write('\0') |
|
517 |
|
518 def runcommand(self): |
443 def runcommand(self): |
519 return super(chgcmdserver, self).runcommand() |
444 return super(chgcmdserver, self).runcommand() |
520 |
445 |
521 def setenv(self): |
446 def setenv(self): |
522 """Clear and update os.environ |
447 """Clear and update os.environ |
533 encoding.environ.update(newenv) |
458 encoding.environ.update(newenv) |
534 |
459 |
535 capabilities = commandserver.server.capabilities.copy() |
460 capabilities = commandserver.server.capabilities.copy() |
536 capabilities.update({'attachio': attachio, |
461 capabilities.update({'attachio': attachio, |
537 'chdir': chdir, |
462 'chdir': chdir, |
538 'getpager': getpager, |
|
539 'runcommand': runcommand, |
463 'runcommand': runcommand, |
540 'setenv': setenv, |
464 'setenv': setenv, |
541 'setumask': setumask}) |
465 'setumask': setumask}) |
542 |
466 |
543 def _tempaddress(address): |
467 def _tempaddress(address): |