obsolete: some more movement
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Tue, 07 Aug 2012 21:39:55 +0200
changeset 448 96c896f0180b
parent 447 fa85e7205e0b
child 449 4f23f224afb4
obsolete: some more movement
hgext/obsolete.py
--- a/hgext/obsolete.py	Tue Aug 07 21:35:39 2012 +0200
+++ b/hgext/obsolete.py	Tue Aug 07 21:39:55 2012 +0200
@@ -342,32 +342,6 @@
     """the set of obsolete parent without non obsolete descendant"""
     return set(repo.revs('obsolete() - obsolete()::unstable()'))
 
-@cachefor('latecomer')
-def _computelatecomerset(repo):
-    """the set of rev trying to obsolete public revision"""
-    query = 'allsuccessors(public()) - obsolete() - public()'
-    return set(repo.revs(query))
-
-@cachefor('conflicting')
-def _computeconflictingset(repo):
-    """the set of rev trying to obsolete public revision"""
-    conflicting = set()
-    obsstore = repo.obsstore
-    newermap = {}
-    for ctx in repo.set('(not public()) - obsolete()'):
-        prec = obsstore.successors.get(ctx.node(), ())
-        toprocess = set(prec)
-        while toprocess:
-            prec = toprocess.pop()[0]
-            if prec not in newermap:
-                newermap[prec] = newerversion(repo, prec)
-            newer = [n for n in newermap[prec] if n] # filter kill
-            if len(newer) > 1:
-                conflicting.add(ctx.rev())
-                break
-        toprocess.update(obsstore.successors.get(prec, ()))
-    return conflicting
-
 @eh.wrapfunction(obsolete.obsstore, '__init__')
 def _initobsstorecache(orig, obsstore, *args, **kwargs):
     """add a caches attributes to obsstore"""
@@ -451,6 +425,32 @@
 ### Complete troubles computation logic                           ###
 #####################################################################
 
+@cachefor('latecomer')
+def _computelatecomerset(repo):
+    """the set of rev trying to obsolete public revision"""
+    query = 'allsuccessors(public()) - obsolete() - public()'
+    return set(repo.revs(query))
+
+@cachefor('conflicting')
+def _computeconflictingset(repo):
+    """the set of rev trying to obsolete public revision"""
+    conflicting = set()
+    obsstore = repo.obsstore
+    newermap = {}
+    for ctx in repo.set('(not public()) - obsolete()'):
+        prec = obsstore.successors.get(ctx.node(), ())
+        toprocess = set(prec)
+        while toprocess:
+            prec = toprocess.pop()[0]
+            if prec not in newermap:
+                newermap[prec] = newerversion(repo, prec)
+            newer = [n for n in newermap[prec] if n] # filter kill
+            if len(newer) > 1:
+                conflicting.add(ctx.rev())
+                break
+        toprocess.update(obsstore.successors.get(prec, ()))
+    return conflicting
+
 @eh.addattr(context.changectx, 'latecomer')
 def latecomer(ctx):
     """is the changeset latecomer (Try to succeed to public change)"""
@@ -465,6 +465,28 @@
         return False
     return ctx.rev() in getobscache(ctx._repo, 'conflicting')
 
+### Discovery wrapping
+
+@eh.wrapfunction(discovery, 'checkheads')
+def wrapcheckheads(orig, repo, remote, outgoing, *args, **kwargs):
+    """wrap mercurial.discovery.checkheads
+
+    * prevent unstability to be pushed
+    * patch remote to ignore obsolete heads on remote
+    """
+    # do not push instability
+    for h in outgoing.missingheads:
+        # Checking heads is enough, obsolete descendants are either
+        # obsolete or unstable.
+        ctx = repo[h]
+        if ctx.latecomer():
+            raise util.Abort(_("push includes a latecomer changeset: %s!")
+                             % ctx)
+        if ctx.conflicting():
+            raise util.Abort(_("push includes a conflicting changeset: %s!")
+                             % ctx)
+    return orig(repo, remote, outgoing, *args, **kwargs)
+
 
 #####################################################################
 ### Additional Utilities                                          ###
@@ -707,27 +729,6 @@
 #####################################################################
 
 
-### Discovery wrapping
-
-@eh.wrapfunction(discovery, 'checkheads')
-def wrapcheckheads(orig, repo, remote, outgoing, *args, **kwargs):
-    """wrap mercurial.discovery.checkheads
-
-    * prevent unstability to be pushed
-    * patch remote to ignore obsolete heads on remote
-    """
-    # do not push instability
-    for h in outgoing.missingheads:
-        # Checking heads is enough, obsolete descendants are either
-        # obsolete or unstable.
-        ctx = repo[h]
-        if ctx.latecomer():
-            raise util.Abort(_("push includes a latecomer changeset: %s!")
-                             % ctx)
-        if ctx.conflicting():
-            raise util.Abort(_("push includes a conflicting changeset: %s!")
-                             % ctx)
-    return orig(repo, remote, outgoing, *args, **kwargs)
 
 @eh.wrapcommand("update")
 @eh.wrapcommand("pull")