Mercurial > public > mercurial-scm > hg-stable
diff mercurial/revset.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 | e7cfe3587ea4 |
children | 31f32a96e1e3 |
line wrap: on
line diff
--- a/mercurial/revset.py Mon Aug 27 09:37:49 2012 -0700 +++ b/mercurial/revset.py Tue Aug 28 20:52:04 2012 +0200 @@ -12,6 +12,7 @@ import match as matchmod from i18n import _ import encoding +import obsolete as obsmod def _revancestors(repo, revs, followfirst): """Like revlog.ancestors(), but supports followfirst.""" @@ -621,8 +622,8 @@ """ # i18n: "extinct" is a keyword getargs(x, 0, 0, _("extinct takes no arguments")) - extinctset = set(repo.revs('(obsolete()::) - (::(not obsolete()))')) - return [r for r in subset if r in extinctset] + extincts = obsmod.getobscache(repo, 'extinct') + return [r for r in subset if r in extincts] def extra(repo, subset, x): """``extra(label, [value])`` @@ -959,7 +960,8 @@ Mutable changeset with a newer version.""" # i18n: "obsolete" is a keyword getargs(x, 0, 0, _("obsolete takes no arguments")) - return [r for r in subset if repo[r].obsolete()] + obsoletes = obsmod.getobscache(repo, 'obsolete') + return [r for r in subset if r in obsoletes] def origin(repo, subset, x): """``origin([set])`` @@ -1437,8 +1439,8 @@ """ # i18n: "unstable" is a keyword getargs(x, 0, 0, _("unstable takes no arguments")) - unstableset = set(repo.revs('(obsolete()::) - obsolete()')) - return [r for r in subset if r in unstableset] + unstables = obsmod.getobscache(repo, 'unstable') + return [r for r in subset if r in unstables] def user(repo, subset, x):