changeset 29887:0c8c388c7d62

lock: show more detail for new-style locks in lock waiting message (issue4752) Improve the lock waiting warning message by explicitly saying that a host and process are holding the lock. This nudges confused new users in the direction of investigating the other process instead of removing the lock.
author Mark Ignacio <mignacio@fb.com>
date Tue, 30 Aug 2016 09:25:00 -0700
parents 307b20e5e505
children ed793f41e83f
files mercurial/localrepo.py tests/test-lock-badness.t
diffstat 2 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Mon Aug 29 00:00:05 2016 +0900
+++ b/mercurial/localrepo.py	Tue Aug 30 09:25:00 2016 -0700
@@ -1290,8 +1290,15 @@
         except error.LockHeld as inst:
             if not wait:
                 raise
-            self.ui.warn(_("waiting for lock on %s held by %r\n") %
-                         (desc, inst.locker))
+            # show more details for new-style locks
+            if ':' in inst.locker:
+                host, pid = inst.locker.split(":", 1)
+                self.ui.warn(
+                    _("waiting for lock on %s held by process %r "
+                      "on host %r\n") % (desc, pid, host))
+            else:
+                self.ui.warn(_("waiting for lock on %s held by %r\n") %
+                             (desc, inst.locker))
             # default to 600 seconds timeout
             l = lockmod.lock(vfs, lockname,
                              int(self.ui.config("ui", "timeout", "600")),
--- a/tests/test-lock-badness.t	Mon Aug 29 00:00:05 2016 +0900
+++ b/tests/test-lock-badness.t	Tue Aug 30 09:25:00 2016 -0700
@@ -60,7 +60,7 @@
   > > preup 2>&1
   $ wait
   $ cat preup
-  waiting for lock on working directory of b held by '*:*' (glob)
+  waiting for lock on working directory of b held by process '*' on host '*' (glob)
   got lock after * seconds (glob)
   $ cat stdout
   adding b