[PATCH 04 of 10 V4] obsolete: add the detection of bumped changeset

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Oct 18 17:52:27 CDT 2012


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1350599778 -7200
# Node ID 9ddc31d21621f5661db72dd4bf70557c74d196a5
# Parent  d17f98db8c9810891717e2aec4154f591ce07dcd
obsolete: add the detection of bumped changeset.

Bumped changesets are non-public changesets that tries to succeed a public()
changeset.

diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -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()'))
 
+
+ at 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
 


More information about the Mercurial-devel mailing list