Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 46793:86b47ec1960a stable
typing: rewrite a conditional assignment to unconfuse pytype
Otherwise, pytype and PyCharm flags it:
File "/mnt/c/Users/Matt/hg/mercurial/localrepo.py", line 2903, in wlock: No attribute 'held' on _weakref.ReferenceType[nothing] [attribute-error]
In Optional[Union[Any, _weakref.ReferenceType[nothing]]]
File "/mnt/c/Users/Matt/hg/mercurial/localrepo.py", line 2904, in wlock: No attribute 'lock' on _weakref.ReferenceType[nothing] [attribute-error]
In Optional[Union[Any, _weakref.ReferenceType[nothing]]]
Differential Revision: https://phab.mercurial-scm.org/D10215
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sat, 13 Mar 2021 02:09:23 -0500 |
parents | 7e08fa9b3d13 |
children | e2f7b2695ba1 |
comparison
equal
deleted
inserted
replaced
46792:7e08fa9b3d13 | 46793:86b47ec1960a |
---|---|
2889 | 2889 |
2890 Use this before modifying files in .hg. | 2890 Use this before modifying files in .hg. |
2891 | 2891 |
2892 If both 'lock' and 'wlock' must be acquired, ensure you always acquires | 2892 If both 'lock' and 'wlock' must be acquired, ensure you always acquires |
2893 'wlock' first to avoid a dead-lock hazard.""" | 2893 'wlock' first to avoid a dead-lock hazard.""" |
2894 l = self._wlockref and self._wlockref() | 2894 l = self._wlockref() if self._wlockref else None |
2895 if l is not None and l.held: | 2895 if l is not None and l.held: |
2896 l.lock() | 2896 l.lock() |
2897 return l | 2897 return l |
2898 | 2898 |
2899 # We do not need to check for non-waiting lock acquisition. Such | 2899 # We do not need to check for non-waiting lock acquisition. Such |