comparison 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
comparison
equal deleted inserted replaced
43582:ae5e39512ca0 43583:73e6d3346e4f
7 # GNU General Public License version 2 or any later version. 7 # GNU General Public License version 2 or any later version.
8 8
9 '''largefiles utility code: must not import other modules in this package.''' 9 '''largefiles utility code: must not import other modules in this package.'''
10 from __future__ import absolute_import 10 from __future__ import absolute_import
11 11
12 import contextlib
12 import copy 13 import copy
13 import hashlib 14 import hashlib
14 import os 15 import os
15 import stat 16 import stat
16 17
35 shortname = b'.hglf' 36 shortname = b'.hglf'
36 shortnameslash = shortname + b'/' 37 shortnameslash = shortname + b'/'
37 longname = b'largefiles' 38 longname = b'largefiles'
38 39
39 # -- Private worker functions ------------------------------------------ 40 # -- Private worker functions ------------------------------------------
41
42
43 @contextlib.contextmanager
44 def lfstatus(repo):
45 oldvalue = getattr(repo, 'lfstatus', False)
46 repo.lfstatus = True
47 try:
48 yield
49 finally:
50 repo.lfstatus = oldvalue
40 51
41 52
42 def getminsize(ui, assumelfiles, opt, default=10): 53 def getminsize(ui, assumelfiles, opt, default=10):
43 lfsize = opt 54 lfsize = opt
44 if not lfsize and assumelfiles: 55 if not lfsize and assumelfiles: