Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 51632:fcc149f3fdcb stable
hooks: add a prewlock and a prelock hooks
This is useful for testing.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 11 Jun 2024 03:03:47 +0200 |
parents | 9da3fcc5f70f |
children | 69c5f8d6c710 |
comparison
equal
deleted
inserted
replaced
51631:3b69324d9535 | 51632:fcc149f3fdcb |
---|---|
3113 l = self._currentlock(self._lockref) | 3113 l = self._currentlock(self._lockref) |
3114 if l is not None: | 3114 if l is not None: |
3115 l.lock() | 3115 l.lock() |
3116 return l | 3116 return l |
3117 | 3117 |
3118 self.hook(b'prelock', throw=True) | |
3118 l = self._lock( | 3119 l = self._lock( |
3119 vfs=self.svfs, | 3120 vfs=self.svfs, |
3120 lockname=b"lock", | 3121 lockname=b"lock", |
3121 wait=wait, | 3122 wait=wait, |
3122 releasefn=None, | 3123 releasefn=None, |
3137 l = self._wlockref() if self._wlockref else None | 3138 l = self._wlockref() if self._wlockref else None |
3138 if l is not None and l.held: | 3139 if l is not None and l.held: |
3139 l.lock() | 3140 l.lock() |
3140 return l | 3141 return l |
3141 | 3142 |
3143 self.hook(b'prewlock', throw=True) | |
3142 # We do not need to check for non-waiting lock acquisition. Such | 3144 # We do not need to check for non-waiting lock acquisition. Such |
3143 # acquisition would not cause dead-lock as they would just fail. | 3145 # acquisition would not cause dead-lock as they would just fail. |
3144 if wait and ( | 3146 if wait and ( |
3145 self.ui.configbool(b'devel', b'all-warnings') | 3147 self.ui.configbool(b'devel', b'all-warnings') |
3146 or self.ui.configbool(b'devel', b'check-locks') | 3148 or self.ui.configbool(b'devel', b'check-locks') |