[PATCH 7 of 7 V3] push: refuse to push bumped changeset

Pierre-Yves David pierre-yves.david at ens-lyon.org
Tue Oct 16 15:48:11 CDT 2012


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1350420189 -7200
# Node ID 2a0450f1ede03ee9d0bf381eac20a0a20d899c0c
# Parent  a3e43e8c10a5970438004bcff6c638d5df622780
push: refuse to push bumped changeset

This applies the same logic as used for `obsolete` and `unstable` changesets.
Refuse to push them without force.

We'll probably want to factor this logic with two new functions `pctx.troubled()`
and  `ctx.troubles()`. But I'm waiting for the third "trouble" to make it into
core.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1880,6 +1880,7 @@
                             # this message are here for 80 char limit reason
                             mso = _("push includes an obsolete changeset: %s!")
                             msu = _("push includes an unstable changeset: %s!")
+                            msb = _("push includes an bumped 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
@@ -1890,6 +1891,8 @@
                                     raise util.Abort(_(mso) % ctx)
                                 elif ctx.unstable():
                                     raise util.Abort(_(msu) % ctx)
+                                elif ctx.bumped():
+                                    raise util.Abort(_(msb) % ctx)
                         discovery.checkheads(self, remote, outgoing,
                                              remoteheads, newbranch,
                                              bool(inc))
diff --git a/tests/test-obsolete-checkheads.t b/tests/test-obsolete-checkheads.t
--- a/tests/test-obsolete-checkheads.t
+++ b/tests/test-obsolete-checkheads.t
@@ -38,6 +38,7 @@
 ==========================
 
 setup
+(we add the 1 flags to prevent bumped error during the test)
 
   $ mkcommit old
   $ hg push
@@ -50,7 +51,7 @@
   $ hg up -q '.^'
   $ mkcommit new
   created new head
-  $ hg debugobsolete `getid old` `getid new`
+  $ hg debugobsolete --flags 1 `getid old` `getid new`
   $ hg glog --hidden
   @  71e3228bffe1 (draft) add new
   |
diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t
--- a/tests/test-obsolete.t
+++ b/tests/test-obsolete.t
@@ -171,6 +171,14 @@
   summary:     add new_3_c
   
 
+And that we can't push bumped changeset
+
+  $ hg push ../tmpa
+  pushing to ../tmpa
+  searching for changes
+  abort: push includes an bumped changeset: 5601fb93a350!
+  [255]
+
 Fixing "bumped" situation
 We need to create a clone of 5 and add a special marker with a flag
 


More information about the Mercurial-devel mailing list