Gregory Szorc <gregory.szorc@gmail.com> [Thu, 13 Sep 2018 15:57:18 -0700] rev 39786
localrepo: enable ellipsis flag on revlogs when repo is narrow
If the narrow requirement is present, revlogs created for that
repository will have the ellipsis flag enabled.
This is the same behavior that the narrow extension exhibits. Except
the ellipsis flag won't be enabled on repos/revlogs that don't have
the narrow requirement.
Differential Revision: https://phab.mercurial-scm.org/D4648
Gregory Szorc <gregory.szorc@gmail.com> [Thu, 13 Sep 2018 15:52:42 -0700] rev 39785
revlog: add opener option to enable ellipsis flag processor
The ellipsis flag processor can now be registered by specifying
an opener option when constructing a revlog instance. This allows
us to enable ellipsis flags on a per-revlog basis.
Differential Revision: https://phab.mercurial-scm.org/D4647
Gregory Szorc <gregory.szorc@gmail.com> [Thu, 13 Sep 2018 15:48:53 -0700] rev 39784
revlog: store flag processors per revlog
Previously, revlog flag processing would consult a global dict
when processing flags. This was simple. But it had the undesired
side-effect that any extension could load flag processors once
and those flag processors would be available to any revlog that was
subsequent loaded in the process. e.g. in hgweb, if the narrow
extension were loaded for repo A but not repo B, repo B would be
able to decode ellipsis flags even though it shouldn't be able to.
Making the flag processors dict per-revlog allows us to have per-revlog
controls over what flag processors are available, thus preserving
desired granular access to flag processors depending on the revlog's
needs.
If a flag processor is globally registered, it is still globally
available. So this commit should not meaningfully change behavior.
Differential Revision: https://phab.mercurial-scm.org/D4646
Gregory Szorc <gregory.szorc@gmail.com> [Wed, 05 Sep 2018 13:29:22 -0700] rev 39783
revlog: define ellipsis flag processors in core
We will soon be teaching core to honor the ellipsis flag on revlogs.
Moving the definition of the processor functions to core is the first
step in this.
The processor is still not registered unless the narrow extension is
loaded.
Differential Revision: https://phab.mercurial-scm.org/D4645
Gregory Szorc <gregory.szorc@gmail.com> [Wed, 05 Sep 2018 12:44:25 -0700] rev 39782
narrow: remove custom filelog type
This functionality is now handled by core as of the previous commit.
I wanted this to be a standalone commit because the deleted code
makes a reference to remotefilelog's file type missing a node() method
and this may have implications to narrow+remotefilelog usage. The code
in core doesn't perform this check and therefore behavior may be subtly
different and buggy.
But I /think/ the check is merely a performance optimization and
nothing more. So I'm optimistic this will continue to "just work."
Differential Revision: https://phab.mercurial-scm.org/D4644
Gregory Szorc <gregory.szorc@gmail.com> [Thu, 13 Sep 2018 16:02:22 -0700] rev 39781
filelog: custom filelog to be used with narrow repos
Narrow repos may have file revisions whose copy/rename metadata
references files not in the store. This can pose problems when
consumers attempt to access a missing referenced file revision.
The narrow extension hacks around this problem by implementing a
derived filelog type that provides custom implementations of
renamed(), size(), and cmp() which handle renames against files not
in the narrow spec by silently removing the rename metadata.
While silently dropping metadata isn't the most robust solution,
it is the easiest to implement.
This commit ports the custom narrow filelog class to core.
When a narrow repo is constructed, its ifilestorage creation
function will automatically use the new filelog type. This means
the extra logic is 0 cost for non-narrow repos and shouldn't
interfere with their operation.
Differential Revision: https://phab.mercurial-scm.org/D4643
Gregory Szorc <gregory.szorc@gmail.com> [Tue, 18 Sep 2018 15:29:42 -0700] rev 39780
localrepo: iteratively derive local repository type
This commit implements the dynamic local repository type derivation
that was explained in the recent commit
bfeab472e3c0 "localrepo: create new function for instantiating a local
repo object."
Instead of a static localrepository class/type which must be customized
after construction, we now dynamically construct a type by building up
base classes/types to represent specific repository interfaces.
Conceptually, the end state is similar to what was happening when
various extensions would monkeypatch the __class__ of newly-constructed
repo instances. However, the approach is inverted. Instead of making
the instance then customizing it, we do the customization up front
by influencing the behavior of the type then we instantiate that
custom type.
This approach gives us much more flexibility. For example, we can
use completely separate classes for implementing different aspects
of the repository. For example, we could have one class representing
revlog-based file storage and another representing non-revlog based
file storage. When then choose which implementation to use based on
the presence of repo requirements.
A concern with this approach is that it creates a lot more types
and complexity and that complexity adds overhead. Yes, it is true that
this approach will result in more types being created. Yes, this is
more complicated than traditional "instantiate a static type." However,
I believe the alternatives to supporting alternate storage backends
are just as complicated. (Before I arrived at this solution, I had
patches storing factory functions on local repo instances for e.g.
constructing a file storage instance. We ended up having a handful
of these. And this was logically identical to assigning custom
methods. Since we were logically changing the type of the instance,
I figured it would be better to just use specialized types instead
of introducing levels of abstraction at run-time.)
On the performance front, I don't believe that having N base classes
has any significant performance overhead compared to just a single base
class. Intuition says that Python will need to iterate the base classes
to find an attribute. However, CPython caches method lookups: as long as
the __class__ or MRO isn't changing, method attribute lookup should be
constant time after first access. And non-method attributes are stored
in __dict__, of which there is only 1 per object, so the number of
base classes for __dict__ is irrelevant.
Anyway, this commit splits up the monolithic completelocalrepository
interface into sub-interfaces: 1 for file storage and 1 representing
everything else.
We've taught ``makelocalrepository()`` to call a series of factory
functions which will produce types implementing specific interfaces.
It then calls type() to create a new type from the built-up list of
base types.
This commit should be considered a start and not the end state. I
suspect we'll hit a number of problems as we start to implement
alternate storage backends:
* Passing custom arguments to __init__ and setting custom attributes
on __dict__.
* Customizing the set of interfaces that are needed. e.g. the
"readonly" intent could translate to not requesting an interface
providing methods related to writing.
* More ergonomic way for extensions to insert themselves so their
callbacks aren't unconditionally called.
* Wanting to modify vfs instances, other arguments passed to __init__.
That being said, this code is usable in its current state and I'm
convinced future commits will demonstrate the value in this approach.
Differential Revision: https://phab.mercurial-scm.org/D4642