D3820: progress: use context manager for lock
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Wed Jun 20 05:44:29 UTC 2018
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D3820
AFFECTED FILES
mercurial/progress.py
CHANGE DETAILS
diff --git a/mercurial/progress.py b/mercurial/progress.py
--- a/mercurial/progress.py
+++ b/mercurial/progress.py
@@ -265,8 +265,7 @@
def progress(self, topic, pos, item='', unit='', total=None):
now = time.time()
- self._refreshlock.acquire()
- try:
+ with self._refreshlock:
if pos is None:
self.starttimes.pop(topic, None)
self.startvals.pop(topic, None)
@@ -298,5 +297,3 @@
if self._oktoprint(now):
self.lastprint = now
self.show(now, topic, *self.topicstates[topic])
- finally:
- self._refreshlock.release()
To: martinvonz, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list