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.
--- 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()