changeset 29186:e0fc0ed41935

transaction: turn lack of locking into a hard failure (API) We have been warning about transactions without locks for about a year (and three releases), third party extensions had a fair grace period to fix their code, we are moving lack of locking to a hard failure in order to protect users against repository corruption.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Thu, 05 May 2016 16:20:53 +0200
parents 28e7f590be2d
children aec5d8561be2
files mercurial/localrepo.py tests/test-devel-warnings.t
diffstat 2 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Thu May 05 16:13:22 2016 +0200
+++ b/mercurial/localrepo.py	Thu May 05 16:20:53 2016 +0200
@@ -1000,7 +1000,8 @@
                 or self.ui.configbool('devel', 'check-locks')):
             l = self._lockref and self._lockref()
             if l is None or not l.held:
-                self.ui.develwarn('transaction with no lock')
+                raise RuntimeError('programming error: transaction requires '
+                                   'locking')
         tr = self.currenttransaction()
         if tr is not None:
             return tr.nest()
--- a/tests/test-devel-warnings.t	Thu May 05 16:13:22 2016 +0200
+++ b/tests/test-devel-warnings.t	Thu May 05 16:20:53 2016 +0200
@@ -159,7 +159,15 @@
 
 Test programming error failure:
 
-  $ hg buggytransaction
-  devel-warn: transaction with no lock at: $TESTTMP/buggylocking.py:* (buggylocking) (glob)
+  $ hg buggytransaction 2>&1 | egrep -v '^  '
+  ** Unknown exception encountered with possibly-broken third-party extension buggylocking
+  ** which supports versions unknown of Mercurial.
+  ** Please disable buggylocking and try your action again.
+  ** If that fixes the bug please report it to the extension author.
+  ** Python * (glob)
+  ** Mercurial Distributed SCM (*) (glob)
+  ** Extensions loaded: * (glob)
+  Traceback (most recent call last):
+  RuntimeError: programming error: transaction requires locking
 
   $ cd ..