Patchwork D3820: progress: use context manager for lock

login
register
mail settings
Submitter phabricator
Date June 21, 2018, 12:44 p.m.
Message ID <8d6a31c85e7236c8ff1d09aa1eff9032@localhost.localdomain>
Download mbox | patch
Permalink /patch/32354/
State Not Applicable
Headers show

Comments

phabricator - June 21, 2018, 12:44 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG6bd9f18d31a8: progress: use context manager for lock (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3820?vs=9236&id=9241

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