mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 07:17:55 +03:00
fastmanifest: allow creating a systemawarecachelimit without a reference to repo
Summary: This will be useful to refactor the cache Test Plan: We change the python test to give a vfs that makes sense, it will be useful in the next patch when we refactor the cache. Indeed, with the new cache we use systemawarecachelimit by default instead of no limit Reviewers: ttung Differential Revision: https://phabricator.intern.facebook.com/D3427796
This commit is contained in:
parent
ef584cd5fe
commit
dcc7566c33
@ -111,10 +111,18 @@ class _systemawarecachelimit(object):
|
||||
repo.ui.warn((msg % strconfig))
|
||||
return configs
|
||||
|
||||
def __init__(self, repo):
|
||||
def __init__(self, repo=None, opener=None, ui=None):
|
||||
# Probe the system root partition to know what is available
|
||||
try:
|
||||
st = os.statvfs(repo.root)
|
||||
if repo is None and (opener is None or ui is None):
|
||||
raise error.Abort("Need to specify repo or (opener and ui)")
|
||||
if repo is not None:
|
||||
st = os.statvfs(repo.root)
|
||||
else:
|
||||
if util.safehasattr(opener, "vfs"):
|
||||
st = os.statvfs(opener.vfs.base)
|
||||
else:
|
||||
st = os.statvfs(opener.base)
|
||||
except (OSError, IOError) as ex:
|
||||
if ex.errno == errno.EACCES:
|
||||
self.free = 0
|
||||
@ -124,7 +132,10 @@ class _systemawarecachelimit(object):
|
||||
self.free = st.f_bavail * st.f_frsize
|
||||
self.total = st.f_blocks * st.f_frsize
|
||||
# Read parameters from config
|
||||
self.config = self.parseconfig(repo)
|
||||
if repo is not None:
|
||||
self.config = self.parseconfig(repo.ui)
|
||||
else:
|
||||
self.config = self.parseconfig(ui)
|
||||
|
||||
def bytes(self):
|
||||
return _systemawarecachelimit.cacheallocation(self.free, **self.config)
|
||||
|
@ -19,7 +19,7 @@ class HybridManifest(unittest.TestCase):
|
||||
breakage in prod
|
||||
|
||||
"""
|
||||
vfs = scmutil.vfs('')
|
||||
vfs = scmutil.vfs(os.getcwd())
|
||||
hd = fastmanifest.implementation.hybridmanifest(ui.ui(), vfs)
|
||||
ismagic = lambda x: x.startswith("__") and x.endswith("__")
|
||||
magicmethods = [k
|
||||
|
Loading…
Reference in New Issue
Block a user