sparse: use with statement for wlock
authorPierre-Yves David <pierre-yves.david@octobus.net>
Tue, 19 Dec 2023 22:03:34 +0100
changeset 51300 fa87eeeb10ca
parent 51299 726d8584905a
child 51301 4b4253b3ec0a
sparse: use with statement for wlock This will avoid pytype complaining about the try/except range.
hgext/sparse.py
--- a/hgext/sparse.py	Tue Dec 19 22:00:47 2023 +0100
+++ b/hgext/sparse.py	Tue Dec 19 22:03:34 2023 +0100
@@ -371,8 +371,7 @@
         sparse.clearrules(repo, force=force)
 
     if refresh:
-        try:
-            wlock = repo.wlock()
+        with repo.wlock():
             fcounts = pycompat.maplist(
                 len,
                 sparse.refreshwdir(
@@ -386,7 +385,5 @@
                 dropped=fcounts[1],
                 conflicting=fcounts[2],
             )
-        finally:
-            wlock.release()
 
     del repo._has_sparse