Commit Graph

1186 Commits

Author SHA1 Message Date
Mads Kiilerich
26b3c84619 localrepo: store requirements sorted 2012-12-12 02:38:14 +01:00
Idan Kamara
ddb5b141cc localrepo: drop unnecessary check on wlock unlock
Calling out to dirstate one line before guarantees that it'll be in the filecache.
2013-01-10 23:57:03 +02:00
Idan Kamara
dc1e34eda3 rollback: don't clear the filecache
This was an old workaround to force the filecache to reload everything. Now
that the syncing issue is fixed, we no longer need it.
2013-01-09 20:36:53 +02:00
Idan Kamara
ca54b38975 destroyed: keep the filecache in sync with __dict__ (issue3335) (issue3693) (issue3743)
We need to make sure that if X is in the filecache then it's also in the
filecache owner's __dict__, otherwise it will go out of sync:

repo.X                  # first access to X, records stat info in
                        # filecache and updates __dict__
repo._filecache.clear() # removes X from _filecache but it's still in __dict__
repo.invalidate()       # iterates over _filecache and removes entries
                        # from __dict__, but X isn't in _filecache, so
                        # it's kept in __dict__
repo.X                  # X is fetched from __dict__, bypassing the filecache
2013-01-09 20:37:44 +02:00
Idan Kamara
b367739fa0 localrepo: write the phasecache when destroying nodes 2013-01-11 00:05:52 +02:00
Idan Kamara
a5fb16be88 localrepo: update the branchmap when destroying nodes
This was previously called directly during strip. Moving it to destroying
also means that it'll be called through _rollback, which seems harmless.
2013-01-05 16:50:12 +02:00
Idan Kamara
bd84da5670 localrepo: introduce destroying function 2012-12-15 20:08:13 +02:00
Idan Kamara
7b192e750c localrepo: don't refresh filecache entries that aren't in __dict__
We call invalidate to remove properties from __dict__ because they're
possibly outdated and we'd like to check for a new version. Next time
the property is accessed the filecache mechanism checks the current stat
info with the one recorded at the last time the property was read, if
they're different it recreates the property.

Previously we refreshed the stat info on all properties in the filecache
when the lock is released, including properties that are missing from
__dict__. This is a problem because:

  l = repo.lock()
  repo.P          # stat info S for P is recorded in _filecache
  <changes are made to repo.P indirectly, e.g. underlying file is replaced>
                  # P's new stat info = S'
  l.release()     # filecache refreshes, records S' as P's stat info

At this point our filecache contains P with stat info S', but P's
version is from S, which is outdated.

The above happens during _rollback and strip. Currently we're wiping the
filecache and forcing everything to reload from scratch which works but
isn't the right solution.
2012-12-16 23:13:02 +02:00
Pierre-Yves David
4bd2fce08b branchmap: pass revision insteads of changectx to the update function
Creation of changectx objects is very slow, and they are not very
useful. We are going to drop them. The first step is to change the
function argument type.
2013-01-08 01:28:39 +01:00
Pierre-Yves David
433ce5d8f8 clfilter: drop extra filtering in localpeer
The repository used by localpeer is already filtered. We no longer
need to call a special function.
2013-01-06 04:28:52 +01:00
Pierre-Yves David
158ce0ffec clfilter: make localpeer use a repo with "unserved" filter
This changeset installs a broad filter on most repos used for
serving. This removes the need to use the `visiblehead`/`visiblebranchmap`
functions, and ensures that changesets we should not serve are in
fact never served.

We do not use filtering on hgweb yet, as there is still a number
of issues to solve there.
2013-01-06 04:41:11 +01:00
Pierre-Yves David
136b6255e0 hidden: drop of the repo.hiddenrevs property
It does not have any user left
2013-01-03 18:52:59 +01:00
Pierre-Yves David
49792eaad1 hidden: drop cache on hiddenrevs property
The `filteredrevs` function already have a cache mechanism. And this cache in
invalidated at the same time than the current property cache. So we drop the
cache on the property.

The property itself is going to be dropped soon.
2013-01-08 14:16:49 +01:00
Pierre-Yves David
d9a61344d3 hidden: move computation in filter function
There is not good reason for this computation to be handle in a different way
from the other. We are moving the computation of hidden revs in the filter
function. In later changesets, code that access to `repo.hiddenrevs` will be
updated and the property dropped.
2013-01-08 14:10:29 +01:00
Pierre-Yves David
9f5750c56a destroyed: filter unknown before computing branchcache
Branchcache of filtered version need up to date phase data.
2013-01-04 19:05:20 +01:00
Pierre-Yves David
dd98ce8d6f branchmap: disable fallback to unfiltered branchcache
Disables this simple optimisation to allow coming more powerfull approach: cache
collaboration.

Our goal is to have branchcache collaborate. This means that unfiltered
branchcache will fallback to some filtered branchcache if invalid. We can't have
the filtered branchcache to use the unfiltered one. That would loop.
2013-01-02 01:36:57 +01:00
Idan Kamara
92fd1426f3 localrepo: filter unknown nodes from the phasecache on destroyed
When commit is followed by strip (qrefresh), phasecache contains nodes that were
removed from the changelog. Since phasecache is filecached with .hg/store/phaseroots
which doesn't change as a result of stripping, we have to filter it manually.

If we don't write it immediately, the next time it is read from disk the nodes
will be filtered again. That's what happened before, but there's no reason not
to write it immediately.

The change in test-keyword.t is caused by the above.
2012-12-21 17:19:52 +01:00
Pierre-Yves David
458159ba53 localrepo: drop _cacheabletip method
It iss dead code now.
2013-01-04 01:37:38 +01:00
Pierre-Yves David
0cd9115520 branchmap: enable caching for filtered version too
The `_branchcache` attribute is turned into a dictionary. Key are filter name and
value is a `branchcache` object. Unfiltered version is cached as `None` filter.

The attribute is renamed to `_branchcaches` to avoid confusion with the previous
one. Both old and new contents are dictionary even if their contents are
different. I prefer possible extension code to crash right away instead of just
messing the wrong dictionary.

As all different caches work isolated to each other, this code keeps the
previous behavior of using the unfiltered cache  we nothing is filtered.  This
is a cheap way to have cache collaborate and nullify potential impact in the
default case.
2012-12-24 03:21:15 +01:00
Pierre-Yves David
c957b56f86 clfilter: ensure unfiltered repo have a filtername attribute too
That will allows to use `repo.filtername` for dispatch purpose.
2012-12-24 03:05:02 +01:00
Pierre-Yves David
1c9929a557 obsolete: factorise troubles detection during push
The use of the two methods introduced earlier allows a factorisation of the
push code preventing push of troubled changeset.
2012-12-21 22:58:59 +01:00
Pierre-Yves David
fc633e8922 strip: do not update branchcache during strip (issue3745)
At this moment, the cache is invalid, and will be thrown away.
Later the strip function will call the `localrepo.destroyed` method
that will update the branchmap cache.
2012-12-28 00:02:40 +01:00
Pierre-Yves David
5e4e0ce72d branchmap: make update a method 2012-12-22 17:08:15 +01:00
Pierre-Yves David
3b1070cfe3 branchmap: make update responsible to update the cache key
The update function have all necessary data to keep the branchcache key
up to date with its value.

This saves assignment to the cache key that each caller of update had to do by
hand.

The strip case is a bit more complicated to handles from inside the function but
I do not expect any impact.
2012-12-24 02:22:04 +01:00
Pierre-Yves David
a3a3d2bc58 branchmap: make write a method on the branchmap object 2012-12-20 16:28:43 +01:00
Pierre-Yves David
1bc937448e branchmap: simplify write signature
All necessary data (cache value and key) are now stored in the branchcache
object. Any extra parameter is superfluous.
2012-12-22 02:04:49 +01:00
Pierre-Yves David
9602b376b6 branchmap: add the tiprev (cache key) on the branchmap object
The actual cache key used on disk is the (tipnode, tiprev) pair. There is no
reason not to use the revision number for the in memory version.
2012-12-22 02:06:26 +01:00
Pierre-Yves David
72ccce9263 branchmap: add the tipnode (cache key) on the branchcache object
Gathering data and cache key paves the way to a lot of simplification.
2012-12-22 01:59:05 +01:00
Pierre-Yves David
0b84a3fa35 branchmap: store branchcache in a dedicated object
Value and key of branchcache would benefit from being hold by the same object.
Moreover some logic (update, write, validation) could be move on such object.

The creation of this object is the first step toward this move. The result will
clarify branchcache related code and hide most of the detail in the class
itself. This encapsulation will greatly helps implementation of branchcache for
filtered view of the repo.
2012-12-22 01:44:42 +01:00
Pierre-Yves David
81a9a63850 branchmap: stream_in write remote branchcache to local one
The previous code was writing it to a non existent `branchcache` attribute.  We
now write is to the proper `_branchcache` attribute and initialize the
`_branchcachetip` at the same time.

We keep writing it to disk, the previous code had this part right.
2012-12-22 01:34:23 +01:00
Pierre-Yves David
dc5b484bd1 branchmap: extract updatebranchcache from repo 2012-12-20 14:45:17 +01:00
Pierre-Yves David
0e27877238 branchmap: extract _updatebranchcache from repo 2012-12-19 14:49:06 +01:00
Pierre-Yves David
92d0e6ec35 branchmap: _updatebranchmap does not need to be filtered
The `_updatebranchmap` method on repo does not need to be filtered as all
callers are already handling filtering themself.

The fact it is filtered may had even lead to buggy behaviors, but by chances the method
make very sparse use of the repo object.
2012-12-19 14:47:38 +01:00
Pierre-Yves David
b588a59cfa branchmap: extract read logic from repo 2012-12-19 14:46:57 +01:00
Pierre-Yves David
ef0f47c598 branchmap: extract write logic from localrepo 2012-12-20 13:37:37 +01:00
Pierre-Yves David
5587346fea branchmap: merge _branchtags into updatebranchcache
Now that nobody overwrite it, there is no reasons for `_branchtags` to remains
separated from `updatebranchcache`.
2012-12-20 13:23:29 +01:00
Pierre-Yves David
18004c817a branchmap: factorise access to changelog in updatebranchcache
This prepares merge of `updatebranchcache` and `_branchtags`.
2012-12-19 17:39:49 +01:00
Pierre-Yves David
6f3f4215a3 branchmap: simplify _branchtags using a new _cacheabletip method
The current _branchtags method is a remnant of an older, much larger function.
Its only remaining role is to help MQ to alter the version of branchcache we
store on disk. As MQ mutates the repository it ensures persistent cache does not
contain anything it is likely to alter.

This changeset makes explicit the stable vs volatile part of repository and
reduces the MQ specific code to the computation of this limit. The main
_branchtags code now handles this possible limit in all cases.

This will help to extract the branchmap logic from the repository.

The new code of _branchtags is a bit duplicated, but as I expect major
refactoring of this section I'm not keen to setup factorisation function here.
2012-12-20 11:52:50 +01:00
Pierre-Yves David
fa2bc9d633 hidden: invalidate hiddenrevs when needed
The `hiddenrevs` cache is volatile too (It use content from `obscache`). When
unsure it is invalidated when necessary. In a near future, the cache will
probably be moved to `revsfiltercache`
2012-12-18 01:51:08 +01:00
Pierre-Yves David
e3f34c0ee1 cache: group obscache and revsfiltercache invalidation in a single function
Both caches are very volatile and needs invalidation on the same kind of event.
revsfiltercache actually depends on the content of revsfiltercache.
2012-12-18 02:04:37 +01:00
Pierre-Yves David
0ea6453a8a clfilter: add a cache on repo for set of revision to filter for a given set.
Recomputing the filtered revisions at every access to changelog is far too
expensive. This changeset introduce a cache for this information. This cache is
hold by the repository (unfiltered repository) and invalidated when necessary.
This cache is not a protected attribute (leading _) because some logic that
invalidate it is not held by the local repo itself.
2012-12-20 17:14:07 +01:00
Pierre-Yves David
4d4c1e240e clfilter: add actual repo filtering mechanism
We add a `filtered` method on repo. This method return an instance of `repoview`
that behaves exactly as the original repository but with a filtered changelog
attribute. Filters are identified by a "name". Planned filter are `unserved`,
`hidden` and `mutable`. Filtering the repository in place what out of question
as it wont not allows multiple thread to share the same repo. It would makes
control of the filtering scope harder too. See the `repoview` docstring for
details.

A mechanism to compute filtered revision is also installed. Some caches will be
installed in later commit.
2012-12-20 15:32:42 +01:00
Siddharth Agarwal
28d6c979cc localrepo: use lazy ancestor membership testing
For a repository with over 400,000 commits, rebasing one revision near tip,
this avoids two treks up the DAG, speeding the operation up by around 1.6
seconds.
2012-12-17 20:43:37 -08:00
Pierre-Yves David
fe7c7f379e clfilter: fix nodemap usage in getbundle
With the current implementation, `changelog.nodemap` is not filtered. So some
filtered changeset in common are not filtered by `n in nodemap`. This leads to
crash lower in the stack when the bundle generation try to access those node on
a filtered changelog.
2012-12-10 18:12:41 +01:00
Pierre-Yves David
2038eca723 obsolete: refuse to push divergent changeset
As other troubles `unstable` and `bumped`. Followup patches may simplify the
push code with unification of "obsolescence troubles" handling.
2012-11-10 02:19:20 +01:00
Mads Kiilerich
ac8e1fc147 check-code: there must also be whitespace between ')' and operator
The check pattern only checked for whitespace between keyword and operator.

Now it also warns:
 >     x = f(),7
 missing whitespace after ,
 >     x = f()+7
 missing whitespace in expression
2012-12-09 23:33:16 +01:00
Kevin Bullock
1ff9eb737c push: reunite comment with the line of code it describes 2012-12-07 12:03:37 -06:00
Pierre-Yves David
5ccc6bfa9a clfilter: rename unfilteredmeth to unfilteredmethod
As originally intended.
2012-11-30 22:34:21 +01:00
Pierre-Yves David
ff24df652d clfilter: ensure that filecache on localrepo is unfiltered
All filecache usage on repo is for logic that should be unfiltered. The
caches should be common to all filtered instances, and computation must
be done unfiltered.  A dedicated storecache subclass is created for
this purpose.
2012-10-08 19:34:04 +02:00
Pierre-Yves David
b25a880a8e clfilter: add a propertycache that must be unfiltered
Some of the localrepo property caches must be computed unfiltered and
stored globally. Some others must see the filtered version and store data
relative to the current filtering.

This changeset introduces two classes `unfilteredpropertycache`
and `filteredpropertycache` for this purpose. A new function
`hasunfilteredcache` is introduced for unambiguous checking for cached
values on unfiltered repos.

A few tweaks are made to the property cache class to allow overriding
the way the computed value is stored on the object.

Some logic relative to _tagcaches is cleaned up in the process.
2012-10-08 20:02:20 +02:00