# HG changeset patch # User Pierre-Yves David # Date 2023-12-19 21:03:34 # Node ID fa87eeeb10cabde2b9852b264a6bda3e17bd1b19 # Parent 726d8584905a6ff2fe1e6d69821a533e672995a5 sparse: use with statement for wlock This will avoid pytype complaining about the try/except range. diff --git a/hgext/sparse.py b/hgext/sparse.py --- a/hgext/sparse.py +++ b/hgext/sparse.py @@ -371,8 +371,7 @@ def debugsparse(ui, repo, **opts): sparse.clearrules(repo, force=force) if refresh: - try: - wlock = repo.wlock() + with repo.wlock(): fcounts = pycompat.maplist( len, sparse.refreshwdir( @@ -386,7 +385,5 @@ def debugsparse(ui, repo, **opts): dropped=fcounts[1], conflicting=fcounts[2], ) - finally: - wlock.release() del repo._has_sparse