devel-warn: issue a warning when writing bookmarks without holding the wlock
authorLaurent Charignon <lcharignon@fb.com>
Sat, 01 Aug 2015 05:43:39 -0700
changeset 26031 0b57b77f9b3e
parent 26030 5243890224ff
child 26032 a3d5da8b641e
devel-warn: issue a warning when writing bookmarks without holding the wlock I saw an issue in an extension that we develop where we were writing bookmarks without holding the wlock. Another extension was taking a lock at the same time and wiped out the bookmarks we were about to write. This patch adds a devel-warning to urge people to fix their invalid code.
mercurial/bookmarks.py
--- a/mercurial/bookmarks.py	Thu Aug 13 19:37:47 2015 -0500
+++ b/mercurial/bookmarks.py	Sat Aug 01 05:43:39 2015 -0700
@@ -90,6 +90,11 @@
         can be copied back on rollback.
         '''
         repo = self._repo
+        if (repo.ui.configbool('devel', 'all-warnings')
+                or repo.ui.configbool('devel', 'check-locks')):
+            l = repo._wlockref and repo._wlockref()
+            if l is None or not l.held:
+                repo.ui.develwarn('bookmarks write with no wlock')
         self._writerepo(repo)
         repo.invalidatevolatilesets()