sapling/hgext
Gregory Szorc a7c49e2ec2 dirstate: expose a sparse matcher on dirstate (API)
The sparse extension performs a lot of monkeypatching of dirstate
to make it sparse aware. Essentially, various operations need to
take the active sparse config into account. They do this by obtaining
a matcher representing the sparse config and filtering paths through
it.

The monkeypatching is done by stuffing a reference to a repo on
dirstate and calling sparse.matcher() (which takes a repo instance)
during each function call. The reason this function takes a repo
instance is because resolving the sparse config may require resolving
file contents from filelogs, and that requires a repo. (If the
current sparse config references "profile" files, the contents of
those files from the dirstate's parent revisions is resolved.)

I seem to recall people having strong opinions that the dirstate
object not have a reference to a repo. So copying what the sparse
extension does probably won't fly in core. Plus, the dirstate
modifications shouldn't require a full repo: they only need a matcher.
So there's no good reason to stuff a reference to the repo in
dirstate.

This commit exposes a sparse matcher to dirstate via a property that
when looked up will call a function that eventually calls
sparse.matcher(). The repo instance is bound in a closure, so it
isn't exposed to dirstate.

This approach is functionally similar to what the sparse extension does
today, except it hides the repo instance from dirstate. The approach
is not optimal because we have to call a proxy function and
sparse.matcher() on every property lookup. There is room to cache
the matcher instance in dirstate. After all, the matcher only changes
if the dirstate's parents change or if the sparse config changes. It
feels like we should be able to detect both events and update the
matcher when this occurs. But for now we preserve the existing
semantics so we can move the dirstate sparseness bits into core. Once
in core, refactoring becomes a bit easier since it will be clearer how
all these components interact.

The sparse extension has been updated to use the new property.
Because all references to the repo on dirstate have been removed,
the code for setting it has been removed.
2017-07-08 16:18:04 -07:00
..
convert convert: remove if False block 2017-07-07 15:08:23 -04:00
fsmonitor fsmonitor: don't write out state if identity has changed (issue5581) 2017-06-12 15:34:31 -07:00
highlight highlight: put pygments import inside demandimport.deactivated 2017-06-18 23:05:54 -04:00
largefiles dirstate: expose a sparse matcher on dirstate (API) 2017-07-08 16:18:04 -07:00
zeroconf zeroconf: blindly forward extra argument to the core config method 2017-07-01 21:57:17 +02:00
__init__.py hgext: officially turn 'hgext' into a namespace package 2016-02-27 12:56:26 +01:00
acl.py configitem: create a new list of each 'acl.sources' access 2017-07-02 23:10:33 +02:00
automv.py configitems: register the 'automv.similarity' config 2017-06-30 03:27:24 +02:00
blackbox.py blackbox: simplify the dirty check 2017-07-09 00:23:03 -04:00
bugzilla.py bugzilla: fix typo in help text 2017-05-31 19:24:00 -03:00
censor.py revlog: rename constants (API) 2017-05-17 19:52:18 -07:00
children.py commands: move templates of common command options to cmdutil (API) 2017-05-14 16:19:47 +09:00
churn.py churn: use the non-deprecated template option in the examples 2017-05-08 23:05:01 -04:00
clonebundles.py clonebundles: fix missing newline character 2017-05-24 22:59:59 -04:00
color.py color: fix grammar in help text 2017-03-25 13:29:23 -04:00
eol.py eol: fix 'error' parameter name in the commitctx wrapper 2017-06-23 13:22:04 +02:00
extdiff.py cmdutil: rename template param to export to fntemplate 2017-05-20 20:15:05 -04:00
factotum.py configitems: register the 'factotum.service' config 2017-06-30 03:42:15 +02:00
fetch.py fetch: remove shorthand of --edit colliding against -e/-ssh in remoteopts (BC) 2017-06-24 02:39:13 +09:00
gpg.py commands: move templates of common command options to cmdutil (API) 2017-05-14 16:19:47 +09:00
graphlog.py commands: move templates of common command options to cmdutil (API) 2017-05-14 16:19:47 +09:00
hgk.py hgk: don't use mutable default argument value 2017-03-14 23:48:25 -07:00
histedit.py histedit: use scmutil.cleanupnodes (BC) 2017-07-08 16:50:31 -07:00
journal.py commands: move templates of common command options to cmdutil (API) 2017-05-14 16:19:47 +09:00
keyword.py keyword: wrap functions only once at loading keyword extension 2017-06-26 03:47:11 +09:00
logtoprocess.py logtoprocess: use lowercase for docstring title 2017-03-23 21:16:55 -07:00
mq.py commands: move templates of common command options to cmdutil (API) 2017-05-14 16:19:47 +09:00
notify.py cmdutil: pass templatespec tuple directly to changeset_templater (API) 2017-04-22 19:02:47 +09:00
pager.py pager: if old pager extensions is enabled, respect pager.attend 2017-03-13 21:43:17 -07:00
patchbomb.py patchbomb: make getaddrs function easier to work with 2017-06-13 17:43:33 -04:00
purge.py commands: move templates of common command options to cmdutil (API) 2017-05-14 16:19:47 +09:00
rebase.py rebase: remove "if True" 2017-07-07 19:03:03 -07:00
record.py commands: move templates of common command options to cmdutil (API) 2017-05-14 16:19:47 +09:00
releasenotes.py releasenotes: improve parsing around bullet points 2017-06-23 17:15:53 +02:00
relink.py extensions: change magic "shipped with hg" string 2016-08-23 11:26:08 -04:00
schemes.py schemes: use br'' literal to define bytes regexp 2017-03-09 19:41:40 -08:00
share.py share: use dict literal instead of dict(key=value) 2017-06-24 13:20:30 +09:00
shelve.py shelve: don't reimplement mergestate.unresolved() 2015-12-01 09:19:54 -08:00
show.py show: document why accidentally quadratic is (probably) acceptable 2017-07-03 21:26:39 -07:00
sparse.py dirstate: expose a sparse matcher on dirstate (API) 2017-07-08 16:18:04 -07:00
strip.py strip: use context manager for locking and transaction in stripcmd() 2017-06-19 11:20:29 -07:00
transplant.py transplant: directly use repo.vfs.join 2017-03-08 16:52:49 -08:00
win32mbcs.py merge with stable 2017-06-03 16:33:28 -04:00
win32text.py win32text: directly use repo.vfs.join 2017-03-08 16:52:57 -08:00