# HG changeset patch # User Pierre-Yves David # Date 1718067827 -7200 # Node ID fcc149f3fdcbd70361afb232292aa6ce344d7481 # Parent 3b69324d95351c1eb0f14668962f2da478898880 hooks: add a prewlock and a prelock hooks This is useful for testing. diff -r 3b69324d9535 -r fcc149f3fdcb mercurial/helptext/config.txt --- a/mercurial/helptext/config.txt Tue Jun 11 11:14:13 2024 +0200 +++ b/mercurial/helptext/config.txt Tue Jun 11 03:03:47 2024 +0200 @@ -1438,6 +1438,12 @@ parent is in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the update failed (e.g. because conflicts were not resolved), ``$HG_ERROR=1``. +``prelock`` + run before the store lock is taken, mostly used for test and debug. + +``prewlock`` + run before the working copy lock is taken, mostly used for test and debug. + .. note:: It is generally better to use standard hooks rather than the diff -r 3b69324d9535 -r fcc149f3fdcb mercurial/localrepo.py --- a/mercurial/localrepo.py Tue Jun 11 11:14:13 2024 +0200 +++ b/mercurial/localrepo.py Tue Jun 11 03:03:47 2024 +0200 @@ -3115,6 +3115,7 @@ l.lock() return l + self.hook(b'prelock', throw=True) l = self._lock( vfs=self.svfs, lockname=b"lock", @@ -3139,6 +3140,7 @@ l.lock() return l + self.hook(b'prewlock', throw=True) # We do not need to check for non-waiting lock acquisition. Such # acquisition would not cause dead-lock as they would just fail. if wait and (