diff hgext/largefiles/lfutil.py @ 43583:73e6d3346e4f

largefiles: move lfstatus context manager to lfutil Differential Revision: https://phab.mercurial-scm.org/D7139
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 18 Oct 2019 17:46:37 -0700
parents eef9a2d67051
children a02e4c12ae60
line wrap: on
line diff
--- a/hgext/largefiles/lfutil.py	Fri Nov 08 14:35:53 2019 -0800
+++ b/hgext/largefiles/lfutil.py	Fri Oct 18 17:46:37 2019 -0700
@@ -9,6 +9,7 @@
 '''largefiles utility code: must not import other modules in this package.'''
 from __future__ import absolute_import
 
+import contextlib
 import copy
 import hashlib
 import os
@@ -39,6 +40,16 @@
 # -- Private worker functions ------------------------------------------
 
 
+@contextlib.contextmanager
+def lfstatus(repo):
+    oldvalue = getattr(repo, 'lfstatus', False)
+    repo.lfstatus = True
+    try:
+        yield
+    finally:
+        repo.lfstatus = oldvalue
+
+
 def getminsize(ui, assumelfiles, opt, default=10):
     lfsize = opt
     if not lfsize and assumelfiles: