D3820: progress: use context manager for lock

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Thu Jun 21 08:44:38 EDT 2018


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

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