Mercurial > public > mercurial-scm > hg
comparison mercurial/revlog.py @ 50590:5ae124310ab0
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:34:25 +0100 |
parents | 814f55775b21 |
children | 32837c7e2e4b |
comparison
equal
deleted
inserted
replaced
50589:0f83dc22efbc | 50590:5ae124310ab0 |
---|---|
1780 | 1780 |
1781 def issnapshot(self, rev): | 1781 def issnapshot(self, rev): |
1782 """tells whether rev is a snapshot""" | 1782 """tells whether rev is a snapshot""" |
1783 if not self._sparserevlog: | 1783 if not self._sparserevlog: |
1784 return self.deltaparent(rev) == nullrev | 1784 return self.deltaparent(rev) == nullrev |
1785 elif util.safehasattr(self.index, b'issnapshot'): | 1785 elif util.safehasattr(self.index, 'issnapshot'): |
1786 # directly assign the method to cache the testing and access | 1786 # directly assign the method to cache the testing and access |
1787 self.issnapshot = self.index.issnapshot | 1787 self.issnapshot = self.index.issnapshot |
1788 return self.issnapshot(rev) | 1788 return self.issnapshot(rev) |
1789 if rev == nullrev: | 1789 if rev == nullrev: |
1790 return True | 1790 return True |