changeset 26488:df2dc5141721

localrepo: add a way to get the current lock if it's held We'll use this in upcoming patches to return a reference to the wlock if it's held.
author Siddharth Agarwal <sid0@fb.com>
date Mon, 05 Oct 2015 14:26:53 -0700
parents 3f234db6fe8d
children 2a3fc0272e3f
files mercurial/localrepo.py
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Thu Sep 24 13:58:18 2015 -0400
+++ b/mercurial/localrepo.py	Mon Oct 05 14:26:53 2015 -0700
@@ -1300,6 +1300,15 @@
         self._wlockref = weakref.ref(l)
         return l
 
+    def _currentlock(self, lockref):
+        """Returns the lock if it's held, or None if it's not."""
+        if lockref is None:
+            return None
+        l = lockref()
+        if l is None or not l.held:
+            return None
+        return l
+
     def _filecommit(self, fctx, manifest1, manifest2, linkrev, tr, changelist):
         """
         commit an individual file as part of a larger transaction