diff mercurial/lock.py @ 20380:c697b70f295f

localrepo: give a sigh of relief when getting lock after waiting for it A message like this was sometimes shown when pushing: remote: waiting for lock on repository foo held by 'mercurial:20858' That could scare users, making them wonder whether the push actually succeeded. To mitigate that fear, issue an additional "warning" such as: got lock after 2 seconds The return value from lock.lock.lock() was unused - instead we return the delay. This also adds the first test coverage for waiting for locks.
author Mads Kiilerich <madski@unity3d.com>
date Thu, 06 Feb 2014 01:55:09 +0100
parents abfe6a8e619b
children f484be02bd35
line wrap: on
line diff
--- a/mercurial/lock.py	Wed Jan 22 15:43:21 2014 -0600
+++ b/mercurial/lock.py	Thu Feb 06 01:55:09 2014 +0100
@@ -38,7 +38,7 @@
         self.desc = desc
         self.postrelease  = []
         self.pid = os.getpid()
-        self.lock()
+        self.delay = self.lock()
 
     def __del__(self):
         if self.held:
@@ -57,7 +57,7 @@
         while True:
             try:
                 self.trylock()
-                return 1
+                return self.timeout - timeout
             except error.LockHeld, inst:
                 if timeout != 0:
                     time.sleep(1)