mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 01:07:15 +03:00
Add missing content from previous diff D3115446
This commit is contained in:
parent
b65983a069
commit
f316c4b25d
@ -32,14 +32,16 @@ class manifestaccesslogger(object):
|
||||
try:
|
||||
with open(self._logfile, "a") as f:
|
||||
f.write("%s\n" % r)
|
||||
except EnvironmentError as e:
|
||||
except EnvironmentError:
|
||||
pass
|
||||
return r
|
||||
|
||||
|
||||
def fastmanifesttocache(repo, subset, x):
|
||||
"""Revset of the interesting revisions to cache"""
|
||||
return repo.revs("not public()")
|
||||
|
||||
|
||||
class fastmanifestcache(object):
|
||||
"""Cache of fastmanifest"""
|
||||
def __contains__(self, key):
|
||||
@ -60,29 +62,27 @@ class hybridmanifest(object):
|
||||
For the moment, behaves like a lazymanifest since cachedmanifest is not
|
||||
yet available.
|
||||
"""
|
||||
def __init__(self, loadflat, cache=None):
|
||||
def __init__(self, loadflat, cache=None, node=None):
|
||||
self.loadflat = loadflat
|
||||
self.cache = cache
|
||||
self.node = node
|
||||
|
||||
@util.propertycache
|
||||
def _flatmanifest(self):
|
||||
k = self.loadflat()
|
||||
if isinstance(k, hybridmanifest):
|
||||
# See comment in extsetup to see why we have to do that
|
||||
k = k.loadflat()
|
||||
assert isinstance(k, manifest.manifestdict), type(k)
|
||||
return k
|
||||
|
||||
@util.propertycache
|
||||
def _cachedmanifest(self):
|
||||
# TODO give the right revision here
|
||||
if not self.incache:
|
||||
return None
|
||||
return self.cache["REVTODO"]
|
||||
return None
|
||||
|
||||
@util.propertycache
|
||||
def _incache(self):
|
||||
# TODO give the right revision here
|
||||
if not self.cache:
|
||||
return None
|
||||
return self.cache.__contains__("REVOTODO")
|
||||
return False
|
||||
|
||||
# Proxy all the manifest methods to the flatmanifest except magic methods
|
||||
def __getattr__(self, name):
|
||||
@ -134,14 +134,16 @@ class hybridmanifest(object):
|
||||
assert type(_m1) == type(_m2)
|
||||
return _m1.diff(_m2, *args, **kwargs)
|
||||
|
||||
|
||||
class manifestfactory(object):
|
||||
def _init__(self):
|
||||
pass
|
||||
def newmanifest(self, orig, *args, **kwargs):
|
||||
loadfn = lambda: orig(*args, **kwargs)
|
||||
return hybridmanifest(loadflat=loadfn)
|
||||
|
||||
def read(self, orig, *args, **kwargs):
|
||||
loadfn = lambda: orig(*args, **kwargs)
|
||||
hf = hybridmanifest(loadflat=loadfn)
|
||||
return hf
|
||||
return hybridmanifest(loadflat=loadfn, node=args[1])
|
||||
|
||||
|
||||
def extsetup(ui):
|
||||
logfile = ui.config("fastmanifest", "logfile", "")
|
||||
@ -149,9 +151,37 @@ def extsetup(ui):
|
||||
if logfile:
|
||||
logger = manifestaccesslogger(logfile)
|
||||
extensions.wrapfunction(manifest.manifest, 'rev', logger.revwrap)
|
||||
|
||||
# Wraps all the function creating a manifestdict
|
||||
extensions.wrapfunction(manifest.manifest, '_newmanifest', factory.read)
|
||||
# We have to do that because the logic to create manifest can take
|
||||
# 7 different codepaths and we want to retain the node information
|
||||
# that comes at the top level:
|
||||
#
|
||||
# read -> _newmanifest ---------------------------> manifestdict
|
||||
#
|
||||
# readshallowfast -> readshallow -----------------> manifestdict
|
||||
# \ \------> _newmanifest --> manifestdict
|
||||
# --> readshallowdelta ------------------------> manifestdict
|
||||
# \->readdelta -------> _newmanifest --> manifestdict
|
||||
# \->slowreaddelta --> _newmanifest --> manifestdict
|
||||
#
|
||||
# othermethods -----------------------------------> manifestdict
|
||||
#
|
||||
# We can have hybridmanifest that wraps one hybridmanifest in some
|
||||
# codepath. We resolve to the correct flatmanifest when asked in the
|
||||
# _flatmanifest method
|
||||
#
|
||||
# The recursion level is at most 2 because we wrap the two top level
|
||||
# functions and _newmanifest (wrapped only for the case of -1)
|
||||
|
||||
extensions.wrapfunction(manifest.manifest, '_newmanifest',
|
||||
factory.newmanifest)
|
||||
extensions.wrapfunction(manifest.manifest, 'read', factory.read)
|
||||
try:
|
||||
extensions.wrapfunction(manifest.manifest, 'readshallowfast',
|
||||
factory.read)
|
||||
except AttributeError:
|
||||
# The function didn't use to be defined in previous versions of hg
|
||||
pass
|
||||
|
||||
revset.symbols['fastmanifesttocache'] = fastmanifesttocache
|
||||
revset.safesymbols.add('fastmanifesttocache')
|
||||
|
Loading…
Reference in New Issue
Block a user