diff hgext/mq.py @ 15952:ec8a9e06cf05 stable

mq-safety: don't apply safety on non-outgoing changeset When mq changeset are secret, they don't appear in outgoing and won't be pushed. So it's not necessary to abort the push. The checkpush call is protected by lock to prevent race on phase.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Fri, 20 Jan 2012 18:45:29 +0100
parents 9d4b5c3cb853
children 341c58282b25
line wrap: on
line diff
--- a/hgext/mq.py	Fri Jan 20 00:27:11 2012 +0100
+++ b/hgext/mq.py	Fri Jan 20 18:45:29 2012 +0100
@@ -3161,15 +3161,22 @@
 
         def checkpush(self, force, revs):
             if self.mq.applied and not force:
-                haspatches = True
+                outapplied = [e.node for e in self.mq.applied]
                 if revs:
-                    # Assume applied patches have no non-patch descendants
-                    # and are not on remote already. If they appear in the
-                    # set of resolved 'revs', bail out.
-                    applied = set(e.node for e in self.mq.applied)
-                    haspatches = bool([n for n in revs if n in applied])
-                if haspatches:
-                    raise util.Abort(_('source has mq patches applied'))
+                    # Assume applied patches have no non-patch descendants and
+                    # are not on remote already. Filtering any changeset not
+                    # pushed.
+                    heads = set(revs)
+                    for node in reversed(outapplied):
+                        if node in heads:
+                            break
+                        else:
+                            outapplied.pop()
+                # looking for pushed and shared changeset
+                for node in outapplied:
+                    if repo[node].phase() < phases.secret:
+                        raise util.Abort(_('source has mq patches applied'))
+                # no non-secret patches pushed
             super(mqrepo, self).checkpush(force, revs)
 
         def _findtags(self):