hgext/obsolete.py
changeset 217 786eb34d93ea
parent 215 0eceb5a48485
child 218 ace5608350b6
--- a/hgext/obsolete.py	Tue Apr 24 15:57:48 2012 +0200
+++ b/hgext/obsolete.py	Tue Apr 24 16:30:58 2012 +0200
@@ -304,6 +304,22 @@
     outgoing.excluded.orig = orig
     return outgoing
 
+def wrapcheckheads(orig, repo, remote, outgoing, *args, **kwargs):
+    """wrap mercurial.discovery.checkheads to prevent unstability to be pushed"""
+    for h in outgoing.missingheads:
+        # checking heads only is enought because any thing base on obsolete
+        # changeset is either obsolete or unstable.
+        ctx =  repo[h]
+        hint = _("use 'hg stabilize' to get a stable history (or --force to proceed)")
+        if ctx.unstable():
+            raise util.Abort(_("Trying to push unstable changeset: %s!") % ctx,
+                             hint=hint)
+        if ctx.obsolete():
+            raise util.Abort(_("Trying to push obsolete changeset: %s!") % ctx,
+                             hint=hint)
+    return orig(repo, remote, outgoing, *args, **kwargs)
+
+
 ### New commands
 #############################
 
@@ -332,6 +348,7 @@
     extensions.wrapcommand(commands.table, "update", wrapmayobsoletewc)
     extensions.wrapcommand(commands.table, "pull", wrapmayobsoletewc)
     extensions.wrapfunction(discovery, 'findcommonoutgoing', wrapfindcommonoutgoing)
+    extensions.wrapfunction(discovery, 'checkheads', wrapcheckheads)
 
 ### serialisation
 #############################
@@ -650,12 +667,8 @@
 
 
     repo.__class__ = obsoletingrepo
-    if repo.ui.configbool('obsolete', 'secret-unstable', True):
-        symbol = 'obsolete()'
-    else:
-        symbol = 'extinct()'
 
-    expobs = [c.node() for c in repo.set('%s - secret()' % symbol)]
+    expobs = [c.node() for c in repo.set('extinct() - secret()')]
     if expobs: # do not lock in nothing move. locking for peanut make hgview reload on any command
         lock = repo.lock()
         try: