Mercurial > public > mercurial-scm > hg
comparison mercurial/subrepoutil.py @ 50603:a30e6401c7f0
safehasattr: pass attribute name as string instead of bytes
This is a step toward replacing `util.safehasattr` usage with plain `hasattr`.
The builtin function behave poorly in Python2 but this was fixed in Python3.
These change are done one by one as they tend to have a small odd to trigger
puzzling breackage.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 02 Feb 2023 17:36:47 +0100 |
parents | 98b805d40c41 |
children | bf7ad17b0a58 |
comparison
equal
deleted
inserted
replaced
50602:98b805d40c41 | 50603:a30e6401c7f0 |
---|---|
413 | 413 |
414 def _abssource(repo, push=False, abort=True): | 414 def _abssource(repo, push=False, abort=True): |
415 # type: (localrepo.localrepository, bool, bool) -> Optional[bytes] | 415 # type: (localrepo.localrepository, bool, bool) -> Optional[bytes] |
416 """return pull/push path of repo - either based on parent repo .hgsub info | 416 """return pull/push path of repo - either based on parent repo .hgsub info |
417 or on the top repo config. Abort or return None if no source found.""" | 417 or on the top repo config. Abort or return None if no source found.""" |
418 if util.safehasattr(repo, b'_subparent'): | 418 if util.safehasattr(repo, '_subparent'): |
419 source = urlutil.url(repo._subsource) | 419 source = urlutil.url(repo._subsource) |
420 if source.isabs(): | 420 if source.isabs(): |
421 return bytes(source) | 421 return bytes(source) |
422 source.path = posixpath.normpath(source.path) | 422 source.path = posixpath.normpath(source.path) |
423 parent = _abssource(repo._subparent, push, abort=False) | 423 parent = _abssource(repo._subparent, push, abort=False) |