[PATCH 9 of 9 V2] push: refuse to push bumped changeset

pierre-yves.david at logilab.fr pierre-yves.david at logilab.fr
Mon Oct 15 07:46:23 CDT 2012


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

This applies the same logic than the one used for `obsolete` and `unstable`
changeset. 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
@@ -1878,20 +1878,23 @@ class localrepository(object):
                         # then, save the iteration
                         if self.obsstore:
                             # 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
                             # unstable. So checking heads only is ok
                             for node in outgoing.missingheads:
                                 ctx = self[node]
                                 if ctx.obsolete():
                                     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))
 
                     # create a changegroup from local
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
@@ -36,10 +36,11 @@ Check that obsolete properly strip heads
 
 New head replaces old head
 ==========================
 
 setup
+(we add the 1 flags to prevent bumped error during the test)
 
   $ mkcommit old
   $ hg push
   pushing to $TESTTMP/remote (glob)
   searching for changes
@@ -48,11 +49,11 @@ setup
   adding file changes
   added 1 changesets with 1 changes to 1 files
   $ 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
   |
   | x  c70b08862e08 (draft) add old
   |/
diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t
--- a/tests/test-obsolete.t
+++ b/tests/test-obsolete.t
@@ -169,10 +169,18 @@ the public changset
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
   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
 
   $ hg up '5^'
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved


More information about the Mercurial-devel mailing list