Mercurial > public > mercurial-scm > hg-stable
diff mercurial/subrepoutil.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 | bf7ad17b0a58 |
children | 18c8c18993f0 |
line wrap: on
line diff
--- a/mercurial/subrepoutil.py Thu Dec 08 15:33:19 2022 +0100 +++ b/mercurial/subrepoutil.py Thu Aug 31 23:56:15 2023 +0200 @@ -384,7 +384,7 @@ Either absolute or relative the outermost repo""" parent = repo chunks = [] - while util.safehasattr(parent, '_subparent'): + while hasattr(parent, '_subparent'): source = urlutil.url(parent._subsource) chunks.append(bytes(source)) if source.isabs(): @@ -400,7 +400,7 @@ # type: (localrepo.localrepository) -> bytes """return path to this (sub)repo as seen from outermost repo""" parent = repo - while util.safehasattr(parent, '_subparent'): + while hasattr(parent, '_subparent'): parent = parent._subparent return repo.root[len(pathutil.normasprefix(parent.root)) :] @@ -415,7 +415,7 @@ # type: (localrepo.localrepository, bool, bool) -> Optional[bytes] """return pull/push path of repo - either based on parent repo .hgsub info or on the top repo config. Abort or return None if no source found.""" - if util.safehasattr(repo, '_subparent'): + if hasattr(repo, '_subparent'): source = urlutil.url(repo._subsource) if source.isabs(): return bytes(source) @@ -428,7 +428,7 @@ return bytes(parent) else: # recursion reached top repo path = None - if util.safehasattr(repo, '_subtoppath'): + if hasattr(repo, '_subtoppath'): path = repo._subtoppath elif push and repo.ui.config(b'paths', b'default-push'): path = repo.ui.config(b'paths', b'default-push')