Mercurial > hg
comparison mercurial/manifest.py @ 29959:483003c27938
manifest: move treeinmem onto manifestlog
A previous patched moved all the serialization related options onto
manifestrevlog (since it is responsible for serialization). Let's move the
treeinmem option on manifestlog, since it is responsible for materialization
decisions. This reduces the number of dependencies manifestlog has on the old
manifest type as well, so we can eventually make them completely independent of
each other.
author | Durham Goode <durham@fb.com> |
---|---|
date | Tue, 20 Sep 2016 12:24:01 -0700 |
parents | 1cc93a154723 |
children | da75bc36202c |
comparison
equal
deleted
inserted
replaced
29958:37a36c05dcc3 | 29959:483003c27938 |
---|---|
955 class do not care about the implementation details of the actual manifests | 955 class do not care about the implementation details of the actual manifests |
956 they receive (i.e. tree or flat or lazily loaded, etc).""" | 956 they receive (i.e. tree or flat or lazily loaded, etc).""" |
957 def __init__(self, opener, repo): | 957 def __init__(self, opener, repo): |
958 self._repo = repo | 958 self._repo = repo |
959 | 959 |
960 usetreemanifest = False | |
961 | |
962 opts = getattr(opener, 'options', None) | |
963 if opts is not None: | |
964 usetreemanifest = opts.get('treemanifest', usetreemanifest) | |
965 self._treeinmem = usetreemanifest | |
966 | |
960 # We'll separate this into it's own cache once oldmanifest is no longer | 967 # We'll separate this into it's own cache once oldmanifest is no longer |
961 # used | 968 # used |
962 self._mancache = repo.manifest._mancache | 969 self._mancache = repo.manifest._mancache |
963 | 970 |
964 @property | 971 @property |
965 def _revlog(self): | 972 def _revlog(self): |
966 return self._repo.manifest | |
967 | |
968 @property | |
969 def _oldmanifest(self): | |
970 # _revlog is the same as _oldmanifest right now, but we eventually want | |
971 # to delete _oldmanifest while still allowing manifestlog to access the | |
972 # revlog specific apis. | |
973 return self._repo.manifest | 973 return self._repo.manifest |
974 | 974 |
975 def __getitem__(self, node): | 975 def __getitem__(self, node): |
976 """Retrieves the manifest instance for the given node. Throws a KeyError | 976 """Retrieves the manifest instance for the given node. Throws a KeyError |
977 if not found. | 977 if not found. |
982 # those since they don't implement the full api. | 982 # those since they don't implement the full api. |
983 if (isinstance(cachemf, manifestctx) or | 983 if (isinstance(cachemf, manifestctx) or |
984 isinstance(cachemf, treemanifestctx)): | 984 isinstance(cachemf, treemanifestctx)): |
985 return cachemf | 985 return cachemf |
986 | 986 |
987 if self._oldmanifest._treeinmem: | 987 if self._treeinmem: |
988 m = treemanifestctx(self._revlog, '', node) | 988 m = treemanifestctx(self._revlog, '', node) |
989 else: | 989 else: |
990 m = manifestctx(self._revlog, node) | 990 m = manifestctx(self._revlog, node) |
991 if node != revlog.nullid: | 991 if node != revlog.nullid: |
992 self._mancache[node] = m | 992 self._mancache[node] = m |