[PATCH 5 of 8] manifest: add manifestlog.get to obtain subdirectory instances
durham at fb.com
Tue Sep 20 15:19:29 EDT 2016
On 9/15/16 11:23 AM, Martin von Zweigbergk wrote:
> On Wed, Sep 14, 2016 at 4:04 PM, Durham Goode <durham at fb.com> wrote:
>> # HG changeset patch
>> # User Durham Goode <durham at fb.com>
>> # Date 1473893509 25200
>> # Wed Sep 14 15:51:49 2016 -0700
>> # Node ID 33a7df42b989c555972280f6b84e2fac38babf7b
>> # Parent d41da1522f8efb5bf5aa75a51f0093b1129b6b5a
>> manifest: add manifestlog.get to obtain subdirectory instances
>> Previously manifestlog only allowed obtaining root level manifests. Future
>> patches will need direct access to subdirectory manifests as part of changegroup
>> creation, so let's add a get() function that knows how to deal with
>> diff --git a/mercurial/manifest.py b/mercurial/manifest.py
>> --- a/mercurial/manifest.py
>> +++ b/mercurial/manifest.py
>> @@ -1040,20 +1040,34 @@ class manifestlog(object):
>> """Retrieves the manifest instance for the given node. Throws a KeyError
>> if not found.
>> - if node in self._mancache:
>> - cachemf = self._mancache[node]
>> - # The old manifest may put non-ctx manifests in the cache, so skip
>> - # those since they don't implement the full api.
>> - if (isinstance(cachemf, manifestctx) or
>> - isinstance(cachemf, treemanifestctx)):
>> - return cachemf
>> + return self.get('', node)
>> - if self._treeinmem:
>> - m = treemanifestctx(self._revlog, '', node)
>> + def get(self, dir, node):
>> + """Retrieves the manifest instance for the given node. Throws a KeyError
>> + if not found.
>> + """
>> + if dir:
>> + if self._treeinmem:
>> + m = treemanifestctx(self._revlog.dirlog(dir), dir, node)
> This does not use the _mancache and there doesn't seem to be a
> _mancache on the revlog either. I've forgotten whether or not you plan
> to have one manifestlog per repo or per directory, but I think you
> said per repo. So it seems like only the root directory manifests will
> be cached at this point. Am I reading that right? Perhaps you're
> fixing that later, but even then it seems like an unfortunate
> transitional step to lose it here.
You are right. I'll send a new series with a patch (immediately after
this patch) that changes the manifestlog's cache to have an entry per tree.
More information about the Mercurial-devel