hgext/obsolete.py
changeset 470 a2dfe82f27a0
parent 467 869ddfb98c7e
child 471 8be3973adf34
equal deleted inserted replaced
469:abeb17a9e313 470:a2dfe82f27a0
   485 # - Cache computation
   485 # - Cache computation
   486 # - revset and ctx method
   486 # - revset and ctx method
   487 # - push warning
   487 # - push warning
   488 
   488 
   489 ### Cache computation
   489 ### Cache computation
       
   490 latediff = 1  # flag to prevent taking late comer fix into account
   490 
   491 
   491 @cachefor('latecomer')
   492 @cachefor('latecomer')
   492 def _computelatecomerset(repo):
   493 def _computelatecomerset(repo):
   493     """the set of rev trying to obsolete public revision"""
   494     """the set of rev trying to obsolete public revision"""
   494     query = 'allsuccessors(public()) - obsolete() - public()'
   495     candidates = _allsuccessors(repo, repo.revs('public()'),
   495     return set(repo.revs(query))
   496                                                 haltonflags=latediff)
       
   497     query = '%ld - obsolete() - public()'
       
   498     return set(repo.revs(query, candidates))
   496 
   499 
   497 @cachefor('conflicting')
   500 @cachefor('conflicting')
   498 def _computeconflictingset(repo):
   501 def _computeconflictingset(repo):
   499     """the set of rev trying to obsolete public revision"""
   502     """the set of rev trying to obsolete public revision"""
   500     conflicting = set()
   503     conflicting = set()
   707                 sr = nm.get(sub)
   710                 sr = nm.get(sub)
   708                 if sr is not None:
   711                 if sr is not None:
   709                     cs.add(sr)
   712                     cs.add(sr)
   710     return cs
   713     return cs
   711 
   714 
   712 def _allsuccessors(repo, s):  # XXX we need a better naming
   715 def _allsuccessors(repo, s, haltonflags=0):  # XXX we need a better naming
   713     """transitive successors of a subset"""
   716     """transitive successors of a subset
       
   717 
       
   718     haltonflags allows to provide flags which prevent the evaluation of a
       
   719     marker.  """
   714     toproceed = [repo[r].node() for r in s]
   720     toproceed = [repo[r].node() for r in s]
   715     seen = set()
   721     seen = set()
   716     allobjects = repo.obsstore.precursors
   722     allobjects = repo.obsstore.precursors
   717     while toproceed:
   723     while toproceed:
   718         nc = toproceed.pop()
   724         nc = toproceed.pop()
   719         for mark in allobjects.get(nc, ()):
   725         for mark in allobjects.get(nc, ()):
       
   726             if mark[2] & haltonflags:
       
   727                 continue
   720             for sub in mark[1]:
   728             for sub in mark[1]:
   721                 if sub == nullid:
   729                 if sub == nullid:
   722                     continue # should not be here!
   730                     continue # should not be here!
   723                 if sub not in seen:
   731                 if sub not in seen:
   724                     seen.add(sub)
   732                     seen.add(sub)