comparison mercurial/localrepo.py @ 17469:fb72eec7efd8

obsolete: introduce caches for all meaningful sets This changeset introduces caches on the `obsstore` that keeps track of sets of revisions meaningful for obsolescence related logics. For now they are: - obsolete: changesets used as precursors (and not public), - extinct: obsolete changesets with osbolete descendants only, - unstable: non obsolete changesets with obsolete ancestors. The cache is accessed using the `getobscache(repo, '<set-name>')` function which builds the cache on demand. The `clearobscaches(repo)` function takes care of clearing the caches if any. Caches are cleared when one of these events happens: - a new marker is added, - a new changeset is added, - some changesets are made public, - some public changesets are demoted to draft or secret. Declaration of more sets is made easy because we will have to handle at least two other "troubles" (latecomer and conflicting). Caches are now used by revset and changectx. It is usually not much more expensive to compute the whole set than to check the property of a few elements. The performance boost is welcome in case we apply obsolescence logic on a lot of revisions. This makes the feature usable!
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Tue, 28 Aug 2012 20:52:04 +0200
parents 038f4f0439d7
children 31f32a96e1e3
comparison
equal deleted inserted replaced
17460:a306837f8c87 17469:fb72eec7efd8
1040 1040
1041 delcache('_tagscache') 1041 delcache('_tagscache')
1042 1042
1043 self._branchcache = None # in UTF-8 1043 self._branchcache = None # in UTF-8
1044 self._branchcachetip = None 1044 self._branchcachetip = None
1045 obsolete.clearobscaches(self)
1045 1046
1046 def invalidatedirstate(self): 1047 def invalidatedirstate(self):
1047 '''Invalidates the dirstate, causing the next call to dirstate 1048 '''Invalidates the dirstate, causing the next call to dirstate
1048 to check if it was modified since the last time it was read, 1049 to check if it was modified since the last time it was read,
1049 rereading it if it has. 1050 rereading it if it has.
2402 htext = _(" (%+d heads)") % dh 2403 htext = _(" (%+d heads)") % dh
2403 2404
2404 self.ui.status(_("added %d changesets" 2405 self.ui.status(_("added %d changesets"
2405 " with %d changes to %d files%s\n") 2406 " with %d changes to %d files%s\n")
2406 % (changesets, revisions, files, htext)) 2407 % (changesets, revisions, files, htext))
2408 obsolete.clearobscaches(self)
2407 2409
2408 if changesets > 0: 2410 if changesets > 0:
2409 p = lambda: cl.writepending() and self.root or "" 2411 p = lambda: cl.writepending() and self.root or ""
2410 self.hook('pretxnchangegroup', throw=True, 2412 self.hook('pretxnchangegroup', throw=True,
2411 node=hex(cl.node(clstart)), source=srctype, 2413 node=hex(cl.node(clstart)), source=srctype,