[PATCH 2 of 4 V5] localrepo: adds times parameter to lock and wlock functions

liscju piotr.listkiewicz at gmail.com
Thu Nov 12 07:17:45 CST 2015


# HG changeset patch
# User liscju <piotr.listkiewicz at gmail.com>
# Date 1447331898 -3600
#      Thu Nov 12 13:38:18 2015 +0100
# Node ID 8b107a3648068503b154eef2bf9f08c4cd13a51b
# Parent  3a0f7224a3466e49068c0cd355640152631d1ba3
localrepo: adds times parameter to lock and wlock functions

This gives a possibility for acquiring/releasing repository
lock and wlock multiple times.

diff -r 3a0f7224a346 -r 8b107a364806 mercurial/localrepo.py
--- a/mercurial/localrepo.py	Thu Nov 12 13:35:22 2015 +0100
+++ b/mercurial/localrepo.py	Thu Nov 12 13:38:18 2015 +0100
@@ -1238,7 +1238,7 @@
             ce.refresh()
 
     def _lock(self, vfs, lockname, wait, releasefn, acquirefn, desc,
-              inheritchecker=None, parentenvvar=None):
+              inheritchecker=None, parentenvvar=None, times=1):
         parentlock = None
         # the contents of parentenvvar are used by the underlying lock to
         # determine whether it can be inherited
@@ -1248,7 +1248,7 @@
             l = lockmod.lock(vfs, lockname, 0, releasefn=releasefn,
                              acquirefn=acquirefn, desc=desc,
                              inheritchecker=inheritchecker,
-                             parentlock=parentlock)
+                             parentlock=parentlock, times=times)
         except error.LockHeld as inst:
             if not wait:
                 raise
@@ -1258,7 +1258,7 @@
             l = lockmod.lock(vfs, lockname,
                              int(self.ui.config("ui", "timeout", "600")),
                              releasefn=releasefn, acquirefn=acquirefn,
-                             desc=desc)
+                             desc=desc, times=times)
             self.ui.warn(_("got lock after %s seconds\n") % l.delay)
         return l
 
@@ -1275,7 +1275,7 @@
         else: # no lock have been found.
             callback()
 
-    def lock(self, wait=True):
+    def lock(self, wait=True, times=1):
         '''Lock the repository store (.hg/store) and return a weak reference
         to the lock. Use this before modifying the store (e.g. committing or
         stripping). If you are opening a transaction, get a lock as well.)
@@ -1284,11 +1284,11 @@
         'wlock' first to avoid a dead-lock hazard.'''
         l = self._lockref and self._lockref()
         if l is not None and l.held:
-            l.lock()
+            l.lock(times)
             return l
 
         l = self._lock(self.svfs, "lock", wait, None,
-                       self.invalidate, _('repository %s') % self.origroot)
+                       self.invalidate, _('repository %s') % self.origroot, times=times)
         self._lockref = weakref.ref(l)
         return l
 
@@ -1297,7 +1297,7 @@
             raise error.LockInheritanceContractViolation(
                 'wlock cannot be inherited in the middle of a transaction')
 
-    def wlock(self, wait=True):
+    def wlock(self, wait=True, times=1):
         '''Lock the non-store parts of the repository (everything under
         .hg except .hg/store) and return a weak reference to the lock.
 
@@ -1307,7 +1307,7 @@
         'wlock' first to avoid a dead-lock hazard.'''
         l = self._wlockref and self._wlockref()
         if l is not None and l.held:
-            l.lock()
+            l.lock(times)
             return l
 
         # We do not need to check for non-waiting lock acquisition.  Such
@@ -1330,7 +1330,7 @@
                        self.invalidatedirstate, _('working directory of %s') %
                        self.origroot,
                        inheritchecker=self._wlockchecktransaction,
-                       parentenvvar='HG_WLOCK_LOCKER')
+                       parentenvvar='HG_WLOCK_LOCKER', times=times)
         self._wlockref = weakref.ref(l)
         return l
 


More information about the Mercurial-devel mailing list