Mercurial > public > mercurial-scm > hg
comparison mercurial/chgserver.py @ 50925:d718eddf01d9
safehasattr: drop usage in favor of hasattr
The two functions should now be equivalent at least in their usage in core.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 31 Aug 2023 23:56:15 +0200 |
parents | defd2b3eafdb |
children | 18c8c18993f0 |
comparison
equal
deleted
inserted
replaced
50924:7a8ea1397816 | 50925:d718eddf01d9 |
---|---|
234 # b. or stdout is redirected by protectfinout(), | 234 # b. or stdout is redirected by protectfinout(), |
235 # because the chg client is not aware of these situations and | 235 # because the chg client is not aware of these situations and |
236 # will behave differently (i.e. write to stdout). | 236 # will behave differently (i.e. write to stdout). |
237 if ( | 237 if ( |
238 out is not self.fout | 238 out is not self.fout |
239 or not util.safehasattr(self.fout, 'fileno') | 239 or not hasattr(self.fout, 'fileno') |
240 or self.fout.fileno() != procutil.stdout.fileno() | 240 or self.fout.fileno() != procutil.stdout.fileno() |
241 or self._finoutredirected | 241 or self._finoutredirected |
242 ): | 242 ): |
243 return procutil.system(cmd, environ=environ, cwd=cwd, out=out) | 243 return procutil.system(cmd, environ=environ, cwd=cwd, out=out) |
244 self.flush() | 244 self.flush() |
260 from . import dispatch # avoid cycle | 260 from . import dispatch # avoid cycle |
261 | 261 |
262 newui = srcui.__class__.load() | 262 newui = srcui.__class__.load() |
263 for a in ['fin', 'fout', 'ferr', 'environ']: | 263 for a in ['fin', 'fout', 'ferr', 'environ']: |
264 setattr(newui, a, getattr(srcui, a)) | 264 setattr(newui, a, getattr(srcui, a)) |
265 if util.safehasattr(srcui, '_csystem'): | 265 if hasattr(srcui, '_csystem'): |
266 newui._csystem = srcui._csystem | 266 newui._csystem = srcui._csystem |
267 | 267 |
268 # command line args | 268 # command line args |
269 options = dispatch._earlyparseopts(newui, args) | 269 options = dispatch._earlyparseopts(newui, args) |
270 dispatch._parseconfig(newui, options[b'config']) | 270 dispatch._parseconfig(newui, options[b'config']) |
601 b'setumask': setumask, | 601 b'setumask': setumask, |
602 b'setumask2': setumask2, | 602 b'setumask2': setumask2, |
603 } | 603 } |
604 ) | 604 ) |
605 | 605 |
606 if util.safehasattr(procutil, 'setprocname'): | 606 if hasattr(procutil, 'setprocname'): |
607 | 607 |
608 def setprocname(self): | 608 def setprocname(self): |
609 """Change process title""" | 609 """Change process title""" |
610 name = self._readstr() | 610 name = self._readstr() |
611 self.ui.log(b'chgserver', b'setprocname: %r\n', name) | 611 self.ui.log(b'chgserver', b'setprocname: %r\n', name) |