[PATCH 5 of 8] push: refuse to push unstable changeset without force

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Jul 5 19:27:27 CDT 2012


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1341532508 -7200
# Node ID c7470a6004a1146bdf4f47f1fd2f52fc9d54ca8f
# Parent  0badef45e0dbcc392f4047a448636b868a814125
push: refuse to push unstable changeset 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.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1732,13 +1732,18 @@
                 else:
                     # something to push
                     if not force:
-                        # avoid iterate missing for peanut
+                        # avoid iterate missingheads for peanut
                         if self.obsstore:
-                            msg = "push includes an obsolete changeset: %s!"
-                            for node in outgoing.missing:
+                            msg = "push includes an %s changeset: %s!"
+                            for node in outgoing.missingheads:
                                 ctx = self[node]
+                                bad = None
                                 if ctx.obsolete():
-                                    raise util.Abort(_(msg) % ctx)
+                                    bad = 'obsolete'
+                                elif ctx.unstable():
+                                    bad  = 'unstable'
+                                if bad is not None:
+                                    raise util.Abort(_(msg) % (bad, ctx))
                         discovery.checkheads(self, remote, outgoing,
                                              remoteheads, newbranch,
                                              bool(inc))
diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t
--- a/tests/test-obsolete.t
+++ b/tests/test-obsolete.t
@@ -177,7 +177,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()'
@@ -295,3 +295,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]


More information about the Mercurial-devel mailing list