Patchwork D3820: progress: use context manager for lock

login
register
mail settings
Submitter phabricator
Date June 20, 2018, 5:44 a.m.
Message ID <differential-rev-PHID-DREV-v7jqivgirz74dug74xdk-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/32340/
State Superseded
Headers show

Comments

phabricator - June 20, 2018, 5:44 a.m.
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




To: martinvonz, #hg-reviewers
Cc: mercurial-devel

Patch

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()