changeset 17172:12fdaa30063a

push: refuse to push unstable changesets without force User should resolve unstability locally before pushing the same way we encourage user to merge locally instead of pushing a new remote head. If we are to push obsolete changeset, at least one set of the pushed set will be either obsolete or unstable. The check is narrowed to only heads.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Tue, 10 Jul 2012 01:39:03 +0200
parents 9c750c3e4fac
children c621f84dbb35
files mercurial/localrepo.py tests/test-obsolete.t
diffstat 2 files changed, 16 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Fri Jul 06 00:18:09 2012 +0200
+++ b/mercurial/localrepo.py	Tue Jul 10 01:39:03 2012 +0200
@@ -1741,11 +1741,18 @@
                         # then, save the iteration
                         if self.obsstore:
                             # this message are here for 80 char limit reason
-                            msg = _("push includes an obsolete changeset: %s!")
-                            for node in outgoing.missing:
+                            mso = _("push includes an obsolete changeset: %s!")
+                            msu = _("push includes an unstable changeset: %s!")
+                            # If we are to push if there is at least one
+                            # obsolete or unstable changeset in missing, at
+                            # least one of the missinghead will be obsolete or
+                            # unstable. So checking heads only is ok
+                            for node in outgoing.missingheads:
                                 ctx = self[node]
                                 if ctx.obsolete():
-                                    raise util.Abort(msg % ctx)
+                                    raise util.Abort(_(mso) % ctx)
+                                elif ctx.unstable():
+                                    raise util.Abort(_(msu) % ctx)
                         discovery.checkheads(self, remote, outgoing,
                                              remoteheads, newbranch,
                                              bool(inc))
--- a/tests/test-obsolete.t	Fri Jul 06 00:18:09 2012 +0200
+++ b/tests/test-obsolete.t	Tue Jul 10 01:39:03 2012 +0200
@@ -196,7 +196,7 @@
   $ hg -R tmpb push tmpd
   pushing to tmpd
   searching for changes
-  abort: push includes an obsolete changeset: cdbce2fbb163!
+  abort: push includes an obsolete changeset: ca819180edb9!
   [255]
   $ hg -R tmpd debugobsolete
   $ hg -R tmpb push tmpd --rev 'not obsolete()'
@@ -315,3 +315,8 @@
      date:        Thu Jan 01 00:00:00 1970 +0000
      summary:     add a
   
+  $ hg push ../tmpc/
+  pushing to ../tmpc/
+  searching for changes
+  abort: push includes an unstable changeset: 7878242aeece!
+  [255]