Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hg.py @ 50605:c04abc7340f1
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:26:23 +0100 |
parents | 3a2df812e1c7 |
children | 029fe2f012c8 |
comparison
equal
deleted
inserted
replaced
50604:9a322ccd2fdc | 50605:c04abc7340f1 |
---|---|
315 If repo is not a shared repository, returns None. | 315 If repo is not a shared repository, returns None. |
316 """ | 316 """ |
317 if repo.sharedpath == repo.path: | 317 if repo.sharedpath == repo.path: |
318 return None | 318 return None |
319 | 319 |
320 if util.safehasattr(repo, b'srcrepo') and repo.srcrepo: | 320 if util.safehasattr(repo, 'srcrepo') and repo.srcrepo: |
321 return repo.srcrepo | 321 return repo.srcrepo |
322 | 322 |
323 # the sharedpath always ends in the .hg; we want the path to the repo | 323 # the sharedpath always ends in the .hg; we want the path to the repo |
324 source = repo.vfs.split(repo.sharedpath)[0] | 324 source = repo.vfs.split(repo.sharedpath)[0] |
325 srcurl, branches = urlutil.parseurl(source) | 325 srcurl, branches = urlutil.parseurl(source) |