# HG changeset patch # User Pierre-Yves David # Date 1324293540 -3600 # Node ID a2e8057117d3f54b00dfdbc218725c2547085834 # Parent 85271a8a7fb9e4cd9f8a5ea5fbeef66cc9815419 obsolete: smarter initialisation of obsolete stuff from disk. diff -r 85271a8a7fb9 -r a2e8057117d3 hgext/obsolete.py --- a/hgext/obsolete.py Mon Dec 19 12:18:04 2011 +0100 +++ b/hgext/obsolete.py Mon Dec 19 12:19:00 2011 +0100 @@ -116,8 +116,8 @@ shown = ['not obsolete()', '.', 'bookmark()', 'tagged()', 'publishedheads()'] basicquery = 'obsolete() - (::(%s))' % (' or '.join(shown)) - for rev in scmutil.revrange(ctx._repo, [basicquery]): - ctx._repo.changelog.hiddenrevs.add(rev) + ctx._repo.changelog.hiddenrevs.update( + scmutil.revrange(ctx._repo, [basicquery])) ctx._repo.changelog.hiddeninit = True return ohidden(ctx) @@ -130,7 +130,7 @@ """filter obsolet entry""" args = revset.getargs(x, 0, 0, 'publicheads takes no arguments') # XXX slow stop using context - return [r for r in subset if repo[r].obsolete()] + return [r for r in subset if r in repo._obsoleteset] ### Other Extension compat ############################ @@ -331,6 +331,16 @@ """return the set of node that make obsolete (sub)""" return self._obssubrels.get(node, set()) + @util.propertycache + def _obsoleteset(self): + obs = set() + for obj in self._obsobjrels: + try: + obs.add(self.changelog.rev(obj)) + except error.LookupError: + pass + return obs + def addobsolete(self, sub, obj): """Add a relation marking that node is a new version of """ if sub == nullid: @@ -351,6 +361,12 @@ except (error.RepoLookupError, error.LookupError): pass #unknow revision (but keep propagating the data self._writeobsrels() + if '_obsobjrels' in vars(self): + del self._obsobjrels + if '_obssubrels' in vars(self): + del self._obssubrels + if '_obsoleteset' in vars(self): + del self._obsoleteset ### obsolete storage @util.propertycache