Mercurial > public > mercurial-scm > hg-stable
diff mercurial/context.py @ 17171:9c750c3e4fac
obsolete: compute unstable changeset
An unstable changeset is a changeset *not* obsolete but with some obsolete
ancestors.
The current logic to decide if a changeset is unstable is naive and very
inefficient. A better solution is to compute the set of unstable changeset with
a simple revset and to cache the result. But this require cache invalidation
logic. Simpler version goes first.
author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
---|---|
date | Fri, 06 Jul 2012 00:18:09 +0200 |
parents | b3c20b0f5f5a |
children | c621f84dbb35 |
line wrap: on
line diff
--- a/mercurial/context.py Fri Jul 06 19:29:10 2012 +0200 +++ b/mercurial/context.py Fri Jul 06 00:18:09 2012 +0200 @@ -235,6 +235,21 @@ return (self.node() in self._repo.obsstore.precursors and self.phase() > phases.public) + def unstable(self): + """True if the changeset is not obsolete but it's ancestor are""" + # We should just compute /(obsolete()::) - obsolete()/ + # and keep it in a cache. + # + # But this naive implementation does not require cache + if self.phase() <= phases.public: + return False + if self.obsolete(): + return False + for anc in self.ancestors(): + if anc.obsolete(): + return True + return False + def _fileinfo(self, path): if '_manifest' in self.__dict__: try: