push: refuse to push obsolete changesets
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Tue, 10 Jul 2012 01:32:18 +0200
changeset 17169 c18ecebed3f1
parent 17168 e058f4eec69c
child 17170 63a4a3871607
push: refuse to push obsolete changesets This is a first version. Simple but not very efficient. Note that this changeset introduce the "obsolete" word in the UI.
mercurial/localrepo.py
tests/test-obsolete.t
--- a/mercurial/localrepo.py	Thu Jul 05 19:53:04 2012 +0200
+++ b/mercurial/localrepo.py	Tue Jul 10 01:32:18 2012 +0200
@@ -1737,6 +1737,15 @@
                 else:
                     # something to push
                     if not force:
+                        # if self.obsstore == False --> no obsolete
+                        # 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:
+                                ctx = self[node]
+                                if ctx.obsolete():
+                                    raise util.Abort(msg % ctx)
                         discovery.checkheads(self, remote, outgoing,
                                              remoteheads, newbranch,
                                              bool(inc))
--- a/tests/test-obsolete.t	Thu Jul 05 19:53:04 2012 +0200
+++ b/tests/test-obsolete.t	Tue Jul 10 01:32:18 2012 +0200
@@ -190,10 +190,16 @@
   $ hg -R tmpb push tmpd
   pushing to tmpd
   searching for changes
+  abort: push includes an obsolete changeset: cdbce2fbb163!
+  [255]
+  $ hg -R tmpd debugobsolete
+  $ hg -R tmpb push tmpd --rev 5601fb93a350 --rev 245bde4270cd
+  pushing to tmpd
+  searching for changes
   adding changesets
   adding manifests
   adding file changes
-  added 6 changesets with 6 changes to 6 files (+3 heads)
+  added 4 changesets with 4 changes to 4 files (+1 heads)
   $ hg -R tmpd debugobsolete
   245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f 0 {'date': '56 12', 'user': 'test'}
   cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'}