hgext/journal.py
changeset 29928 e5a97ec6ebb8
parent 29870 6d11ae3c4c4b
child 30131 85d5708eae4e
--- a/hgext/journal.py	Tue Sep 13 17:46:29 2016 +0200
+++ b/hgext/journal.py	Tue Sep 13 20:30:19 2016 +0200
@@ -267,9 +267,21 @@
         # with a non-local repo (cloning for example).
         cls._currentcommand = fullargs
 
+    def _currentlock(self, lockref):
+        """Returns the lock if it's held, or None if it's not.
+
+        (This is copied from the localrepo class)
+        """
+        if lockref is None:
+            return None
+        l = lockref()
+        if l is None or not l.held:
+            return None
+        return l
+
     def jlock(self, vfs):
         """Create a lock for the journal file"""
-        if self._lockref and self._lockref():
+        if self._currentlock(self._lockref) is not None:
             raise error.Abort(_('journal lock does not support nesting'))
         desc = _('journal of %s') % vfs.base
         try: