[PATCH 2 of 3] lock: make message display logic more modular
Boris Feld
boris.feld at octobus.net
Mon Nov 27 18:18:10 EST 2017
# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1511810637 18000
# Mon Nov 27 14:23:57 2017 -0500
# Node ID f40e9671a53992359c622dd9c46050b4ff09c374
# Parent c59808ca8622826083bc997a3181589f47659f93
# EXP-Topic lock-message
# Available At https://bitbucket.org/octobus/mercurial-devel/
# hg pull https://bitbucket.org/octobus/mercurial-devel/ -r f40e9671a539
lock: make message display logic more modular
We are about to rework various things about lock related messages: amount,
timing and where they are displayed.
This changeset makes minor clean up before the storm.
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1598,23 +1598,27 @@ class localrepository(object):
inheritchecker=inheritchecker,
parentlock=parentlock)
+ def printwarning(printer, locker):
+ """issue the usual "waiting on lock" message through any channel"""
+ # show more details for new-style locks
+ if ':' in locker:
+ host, pid = locker.split(":", 1)
+ msg = _("waiting for lock on %s held by process %r "
+ "on host %r\n") % (desc, pid, host)
+ else:
+ msg = _("waiting for lock on %s held by %r\n") % (desc, locker)
+ printer(msg)
+
try:
l = trylock(0)
except error.LockHeld as inst:
if not wait:
raise
- # 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))
+ printwarning(self.ui.warn, inst.locker)
# default to 600 seconds timeout
l = trylock(int(self.ui.config("ui", "timeout")))
- self.ui.warn(_("got lock after %s seconds\n") % l.delay)
+ msg = _("got lock after %s seconds\n") % l.delay
+ self.ui.warn(msg)
return l
def _afterlock(self, callback):
More information about the Mercurial-devel
mailing list