[PATCH 5 of 5] obsolete: refuse to push divergent changeset

Pierre-Yves David pierre-yves.david at ens-lyon.org
Fri Nov 9 19:23:48 CST 2012


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1352510360 -3600
# Node ID 1d12c86e4c0a1100ba43e568000f71fa093f89de
# Parent  5d1110a633901e68a2b526fc3df283f97424fa8f
obsolete: refuse to push divergent changeset

As other troubles `unstable` and `bumped`. Followup patches may simplify the
push code with unification of "obsolescence troubles" handling.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1873,6 +1873,7 @@
                             mso = _("push includes obsolete changeset: %s!")
                             msu = _("push includes unstable changeset: %s!")
                             msb = _("push includes bumped changeset: %s!")
+                            msd = _("push includes divergent 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
@@ -1885,6 +1886,8 @@
                                     raise util.Abort(msu % ctx)
                                 elif ctx.bumped():
                                     raise util.Abort(msb % ctx)
+                                elif ctx.divergent():
+                                    raise util.Abort(msd % ctx)
                         discovery.checkheads(self, remote, outgoing,
                                              remoteheads, newbranch,
                                              bool(inc))
diff --git a/tests/test-obsolete-divergent.t b/tests/test-obsolete-divergent.t
--- a/tests/test-obsolete-divergent.t
+++ b/tests/test-obsolete-divergent.t
@@ -84,6 +84,16 @@
   $ hg log -r 'divergent()'
   2:82623d38b9ba A_1
   3:392fd25390da A_2
+
+check that mercurial refuse to push
+
+  $ hg init ../other
+  $ hg push ../other
+  pushing to ../other
+  searching for changes
+  abort: push includes divergent changeset: 82623d38b9ba!
+  [255]
+
   $ cd ..
 
 


More information about the Mercurial-devel mailing list