Patchwork D7141: largefiles: use context manager for wlock in repo.status() override

login
register
mail settings
Submitter phabricator
Date Nov. 11, 2019, 12:34 p.m.
Message ID <531888f813163a37689f35f825f00a10@localhost.localdomain>
Download mbox | patch
Permalink /patch/43108/
State Not Applicable
Headers show

Comments

phabricator - Nov. 11, 2019, 12:34 p.m.
Closed by commit rHG99b881195abf: largefiles: use context manager for wlock in repo.status() override (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7141?vs=17353&id=18006

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7141/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7141

AFFECTED FILES
  hgext/largefiles/reposetup.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers, pulkit
Cc: mercurial-devel

Patch

diff --git a/hgext/largefiles/reposetup.py b/hgext/largefiles/reposetup.py
--- a/hgext/largefiles/reposetup.py
+++ b/hgext/largefiles/reposetup.py
@@ -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)