Commits

Pierre-Yves David  committed 786eb34

obsolete: refuse to push unstable changeset without -f

We do not alter phase of suspended and unstable changeset anymore. But push
refuse to push them without force.

The extinct part of the history stay secret for simplicity shake.

  • Participants
  • Parent commits 9400e23

Comments (0)

Files changed (3)

File docs/tutorials/tutorial.t

   (run 'hg heads .' to see heads, 'hg merge' to merge)
   1 new unstables changesets
   $ hg log
-  9ac5d0e790a2 (secret): animals
+  9ac5d0e790a2 (draft): animals
   ffa278c50818 (draft): bathroom stuff
-  8a79ae8b029e (secret): bathroom stuff
+  8a79ae8b029e (draft): bathroom stuff
   a2fccc2e7b08 (public): SPAM SPAM
   387187ad9bd9 (public): adding fruit
   dfd3a2d7691e (public): adding condiment
   9ca060c80d74 (public): SPAM
   7e82d3f3c2cb (public): Monthy Python Shopping list
 
-# XXX Changeset have turned secret because of current implementation of mutable.
 
 The new changeset "animal" is based one an old changeset of "bathroom". You can
 see both version showing up the log.
 
   $ hg glog
-  o  9ac5d0e790a2 (secret): animals
+  o  9ac5d0e790a2 (draft): animals
   |
   | @  ffa278c50818 (draft): bathroom stuff
   | |
-  o |  8a79ae8b029e (secret): bathroom stuff
+  o |  8a79ae8b029e (draft): bathroom stuff
   |/
   o  a2fccc2e7b08 (public): SPAM SPAM
   |
 The old version of bathroom is hidden again now.
 
   $ hg log
-  437efbcaf700 (secret): animals
+  437efbcaf700 (draft): animals
   ffa278c50818 (draft): bathroom stuff
   a2fccc2e7b08 (public): SPAM SPAM
   387187ad9bd9 (public): adding fruit
   9ca060c80d74 (public): SPAM
   7e82d3f3c2cb (public): Monthy Python Shopping list
 
-XXX remove me when fixed
-restore a proper phase for animals
-
-  $ hg ph -dv 437efbcaf700
-  phase changed for 1 changesets
 
 We can push this evolution to remote
 
 is neither dead or obsolete.  My repository is in an unstable state again.
 
   $ hg log
-  ae45c0c3092a (secret): SPAM SPAM SPAM
-  437efbcaf700 (secret): animals
+  ae45c0c3092a (draft): SPAM SPAM SPAM
+  437efbcaf700 (draft): animals
   ffa278c50818 (draft): bathroom stuff
   a2fccc2e7b08 (public): SPAM SPAM
   387187ad9bd9 (public): adding fruit
   7e82d3f3c2cb (public): Monthy Python Shopping list
 
   $ hg log -r 'unstable()'
-  ae45c0c3092a (secret): SPAM SPAM SPAM
+  ae45c0c3092a (draft): SPAM SPAM SPAM
 
   $ hg log -G
-  o  ae45c0c3092a (secret): SPAM SPAM SPAM
+  o  ae45c0c3092a (draft): SPAM SPAM SPAM
   |
-  o  437efbcaf700 (secret): animals
+  o  437efbcaf700 (draft): animals
   |
   @  ffa278c50818 (draft): bathroom stuff
   |

File hgext/obsolete.py

     outgoing.excluded.orig = orig
     return outgoing
 
+def wrapcheckheads(orig, repo, remote, outgoing, *args, **kwargs):
+    """wrap mercurial.discovery.checkheads to prevent unstability to be pushed"""
+    for h in outgoing.missingheads:
+        # checking heads only is enought because any thing base on obsolete
+        # changeset is either obsolete or unstable.
+        ctx =  repo[h]
+        hint = _("use 'hg stabilize' to get a stable history (or --force to proceed)")
+        if ctx.unstable():
+            raise util.Abort(_("Trying to push unstable changeset: %s!") % ctx,
+                             hint=hint)
+        if ctx.obsolete():
+            raise util.Abort(_("Trying to push obsolete changeset: %s!") % ctx,
+                             hint=hint)
+    return orig(repo, remote, outgoing, *args, **kwargs)
+
+
 ### New commands
 #############################
 
     extensions.wrapcommand(commands.table, "update", wrapmayobsoletewc)
     extensions.wrapcommand(commands.table, "pull", wrapmayobsoletewc)
     extensions.wrapfunction(discovery, 'findcommonoutgoing', wrapfindcommonoutgoing)
+    extensions.wrapfunction(discovery, 'checkheads', wrapcheckheads)
 
 ### serialisation
 #############################
 
 
     repo.__class__ = obsoletingrepo
-    if repo.ui.configbool('obsolete', 'secret-unstable', True):
-        symbol = 'obsolete()'
-    else:
-        symbol = 'extinct()'
 
-    expobs = [c.node() for c in repo.set('%s - secret()' % symbol)]
+    expobs = [c.node() for c in repo.set('extinct() - secret()')]
     if expobs: # do not lock in nothing move. locking for peanut make hgview reload on any command
         lock = repo.lock()
         try:

File tests/test-obsolete.t

   > allow_push = *
   > [phases]
   > publish=False
-  > [obsolete]
-  > secret-unstable=no
   > [alias]
   > odiff=diff --rev 'limit(obsparents(.),1)' --rev .
   > [extensions]
 
   $ hg init ../other-new
   $ hg phase --draft 'secret() - extinct()' # until we fix exclusion
-  $ hg push --traceback ../other-new
+  $ hg push ../other-new
+  pushing to ../other-new
+  searching for changes
+  abort: Trying to push unstable changeset: a7a6f2b5d8a5!
+  (use 'hg stabilize' to get a stable history (or --force to proceed))
+  [255]
+  $ hg push -f ../other-new
   pushing to ../other-new
   searching for changes
   adding changesets
   $ qlog -r 'obsolete()'
   3
   - 0d3f46688ccc
-  $ hg push ../other-new -f # XXX should not have to use -f
+  $ hg push ../other-new
+  pushing to ../other-new
+  searching for changes
+  abort: Trying to push unstable changeset: 95de7fc6918d!
+  (use 'hg stabilize' to get a stable history (or --force to proceed))
+  [255]
+  $ hg push ../other-new -f # use f because there is unstability
   pushing to ../other-new
   searching for changes
   adding changesets
   $ hg push ../other-old
   pushing to ../other-old
   searching for changes
+  abort: Trying to push unstable changeset: 909a0fb57e5d!
+  (use 'hg stabilize' to get a stable history (or --force to proceed))
+  [255]
+  $ hg push -f ../other-old
+  pushing to ../other-old
+  searching for changes
   adding changesets
   adding manifests
   adding file changes