Mercurial > hg
diff hgext/largefiles/reposetup.py @ 43585:99b881195abf
largefiles: use context manager for wlock in repo.status() override
Differential Revision: https://phab.mercurial-scm.org/D7141
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 18 Oct 2019 21:36:19 -0700 |
parents | 0371a8c84827 |
children | d77e8800790b |
line wrap: on
line diff
--- a/hgext/largefiles/reposetup.py Fri Oct 18 17:52:19 2019 -0700 +++ b/hgext/largefiles/reposetup.py Fri Oct 18 21:36:19 2019 -0700 @@ -18,6 +18,7 @@ localrepo, match as matchmod, scmutil, + util, ) from . import ( @@ -130,14 +131,15 @@ if match is None: match = matchmod.always() - wlock = None try: - try: - # updating the dirstate is optional - # so we don't wait on the lock - wlock = self.wlock(False) - except error.LockError: - pass + # updating the dirstate is optional + # so we don't wait on the lock + wlock = self.wlock(False) + gotlock = True + except error.LockError: + wlock = util.nullcontextmanager() + gotlock = False + with wlock: # First check if paths or patterns were specified on the # command line. If there were, and they don't match any @@ -308,13 +310,9 @@ for items in result ] - if wlock: + if gotlock: lfdirstate.write() - finally: - if wlock: - wlock.release() - self.lfstatus = True return scmutil.status(*result)