Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hgweb/hgweb_mod.py @ 50951: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 | b2b8c25f9462 |
children | 18c8c18993f0 |
comparison
equal
deleted
inserted
replaced
50950:7a8ea1397816 | 50951:d718eddf01d9 |
---|---|
32 repoview, | 32 repoview, |
33 templatefilters, | 33 templatefilters, |
34 templater, | 34 templater, |
35 templateutil, | 35 templateutil, |
36 ui as uimod, | 36 ui as uimod, |
37 util, | |
38 wireprotoserver, | 37 wireprotoserver, |
39 ) | 38 ) |
40 | 39 |
41 from . import ( | 40 from . import ( |
42 common, | 41 common, |
401 if style != -1: | 400 if style != -1: |
402 req.qsparams[b'style'] = cmd[:style] | 401 req.qsparams[b'style'] = cmd[:style] |
403 cmd = cmd[style + 1 :] | 402 cmd = cmd[style + 1 :] |
404 | 403 |
405 # avoid accepting e.g. style parameter as command | 404 # avoid accepting e.g. style parameter as command |
406 if util.safehasattr(webcommands, pycompat.sysstr(cmd)): | 405 if hasattr(webcommands, pycompat.sysstr(cmd)): |
407 req.qsparams[b'cmd'] = cmd | 406 req.qsparams[b'cmd'] = cmd |
408 | 407 |
409 if cmd == b'static': | 408 if cmd == b'static': |
410 req.qsparams[b'file'] = b'/'.join(args) | 409 req.qsparams[b'file'] = b'/'.join(args) |
411 else: | 410 else: |
476 res.headers[b'Content-Type'] = ctype | 475 res.headers[b'Content-Type'] = ctype |
477 return getattr(webcommands, pycompat.sysstr(cmd))(rctx) | 476 return getattr(webcommands, pycompat.sysstr(cmd))(rctx) |
478 | 477 |
479 except (error.LookupError, error.RepoLookupError) as err: | 478 except (error.LookupError, error.RepoLookupError) as err: |
480 msg = pycompat.bytestr(err) | 479 msg = pycompat.bytestr(err) |
481 if util.safehasattr(err, 'name') and not isinstance( | 480 if hasattr(err, 'name') and not isinstance( |
482 err, error.ManifestLookupError | 481 err, error.ManifestLookupError |
483 ): | 482 ): |
484 msg = b'revision not found: %s' % err.name | 483 msg = b'revision not found: %s' % err.name |
485 | 484 |
486 res.status = b'404 Not Found' | 485 res.status = b'404 Not Found' |