largefiles: allow "lfstatus" context manager to set value to False
authorMartin von Zweigbergk <martinvonz@google.com>
Fri, 18 Oct 2019 17:52:19 -0700
changeset 43631 a02e4c12ae60
parent 43630 73e6d3346e4f
child 43632 99b881195abf
largefiles: allow "lfstatus" context manager to set value to False Differential Revision: https://phab.mercurial-scm.org/D7140
hgext/largefiles/lfutil.py
--- a/hgext/largefiles/lfutil.py	Fri Oct 18 17:46:37 2019 -0700
+++ b/hgext/largefiles/lfutil.py	Fri Oct 18 17:52:19 2019 -0700
@@ -41,9 +41,9 @@
 
 
 @contextlib.contextmanager
-def lfstatus(repo):
+def lfstatus(repo, value=True):
     oldvalue = getattr(repo, 'lfstatus', False)
-    repo.lfstatus = True
+    repo.lfstatus = value
     try:
         yield
     finally:
@@ -591,12 +591,8 @@
             progress.update(i)
             parents = [p for p in repo[n].parents() if p != node.nullid]
 
-            oldlfstatus = repo.lfstatus
-            repo.lfstatus = False
-            try:
+            with lfstatus(repo, value=False):
                 ctx = repo[n]
-            finally:
-                repo.lfstatus = oldlfstatus
 
             files = set(ctx.files())
             if len(parents) == 2: