hgext/sparse.py
changeset 51300 fa87eeeb10ca
parent 50929 18c8c18993f0
--- 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