changeset 17828:9495be4126ef

obsolete: add the detection of bumped changeset. Bumped changesets are non-public changesets that tries to succeed a public() changeset.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Fri, 19 Oct 2012 00:36:18 +0200
parents 612db9d7e76a
children c73f7a28953c
files mercurial/obsolete.py
diffstat 1 files changed, 23 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/obsolete.py	Tue Oct 16 15:49:58 2012 +0200
+++ b/mercurial/obsolete.py	Fri Oct 19 00:36:18 2012 +0200
@@ -368,7 +368,17 @@
                     seen.add(suc)
                     remaining.add(suc)
 
-# mapping of 'set-name' -> <function to computer this set>
+def _knownrevs(repo, nodes):
+    """yield revision numbers of known nodes passed in parameters
+
+    Unknown revisions are silently ignored."""
+    torev = repo.changelog.nodemap.get
+    for n in nodes:
+        rev = torev(n)
+        if rev is not None:
+            yield rev
+
+# mapping of 'set-name' -> <function to compute this set>
 cachefuncs = {}
 def cachefor(name):
     """Decorator to register a function as computing the cache for a set"""
@@ -432,6 +442,18 @@
     """the set of obsolete parents without non obsolete descendants"""
     return set(repo.revs('obsolete() - obsolete()::unstable()'))
 
+
+@cachefor('bumped')
+def _computebumpedset(repo):
+    """the set of revs trying to obsolete public revisions"""
+    # get all possible bumped changesets
+    tonode = repo.changelog.node
+    publicnodes = (tonode(r) for r in repo.revs('public()'))
+    successors = allsuccessors(repo.obsstore, publicnodes)
+    # revision public or already obsolete don't count as bumped
+    query = '%ld - obsolete() - public()'
+    return set(repo.revs(query, _knownrevs(repo, successors)))
+
 def createmarkers(repo, relations, flag=0, metadata=None):
     """Add obsolete markers between changesets in a repo