hgext/obsolete.py
changeset 217 786eb34d93ea
parent 215 0eceb5a48485
child 218 ace5608350b6
equal deleted inserted replaced
216:9400e234b3d7 217:786eb34d93ea
   302     # nothign was exclude. taking this code path when extinct changeset have
   302     # nothign was exclude. taking this code path when extinct changeset have
   303     # been excluded leads to repository corruption.
   303     # been excluded leads to repository corruption.
   304     outgoing.excluded.orig = orig
   304     outgoing.excluded.orig = orig
   305     return outgoing
   305     return outgoing
   306 
   306 
       
   307 def wrapcheckheads(orig, repo, remote, outgoing, *args, **kwargs):
       
   308     """wrap mercurial.discovery.checkheads to prevent unstability to be pushed"""
       
   309     for h in outgoing.missingheads:
       
   310         # checking heads only is enought because any thing base on obsolete
       
   311         # changeset is either obsolete or unstable.
       
   312         ctx =  repo[h]
       
   313         hint = _("use 'hg stabilize' to get a stable history (or --force to proceed)")
       
   314         if ctx.unstable():
       
   315             raise util.Abort(_("Trying to push unstable changeset: %s!") % ctx,
       
   316                              hint=hint)
       
   317         if ctx.obsolete():
       
   318             raise util.Abort(_("Trying to push obsolete changeset: %s!") % ctx,
       
   319                              hint=hint)
       
   320     return orig(repo, remote, outgoing, *args, **kwargs)
       
   321 
       
   322 
   307 ### New commands
   323 ### New commands
   308 #############################
   324 #############################
   309 
   325 
   310 
   326 
   311 def cmddebugobsolete(ui, repo, subject, object):
   327 def cmddebugobsolete(ui, repo, subject, object):
   330 
   346 
   331 def uisetup(ui):
   347 def uisetup(ui):
   332     extensions.wrapcommand(commands.table, "update", wrapmayobsoletewc)
   348     extensions.wrapcommand(commands.table, "update", wrapmayobsoletewc)
   333     extensions.wrapcommand(commands.table, "pull", wrapmayobsoletewc)
   349     extensions.wrapcommand(commands.table, "pull", wrapmayobsoletewc)
   334     extensions.wrapfunction(discovery, 'findcommonoutgoing', wrapfindcommonoutgoing)
   350     extensions.wrapfunction(discovery, 'findcommonoutgoing', wrapfindcommonoutgoing)
       
   351     extensions.wrapfunction(discovery, 'checkheads', wrapcheckheads)
   335 
   352 
   336 ### serialisation
   353 ### serialisation
   337 #############################
   354 #############################
   338 
   355 
   339 def _obsserialise(obssubrels, flike):
   356 def _obsserialise(obssubrels, flike):
   648 
   665 
   649 
   666 
   650 
   667 
   651 
   668 
   652     repo.__class__ = obsoletingrepo
   669     repo.__class__ = obsoletingrepo
   653     if repo.ui.configbool('obsolete', 'secret-unstable', True):
   670 
   654         symbol = 'obsolete()'
   671     expobs = [c.node() for c in repo.set('extinct() - secret()')]
   655     else:
       
   656         symbol = 'extinct()'
       
   657 
       
   658     expobs = [c.node() for c in repo.set('%s - secret()' % symbol)]
       
   659     if expobs: # do not lock in nothing move. locking for peanut make hgview reload on any command
   672     if expobs: # do not lock in nothing move. locking for peanut make hgview reload on any command
   660         lock = repo.lock()
   673         lock = repo.lock()
   661         try:
   674         try:
   662             phases.retractboundary(repo, 2, expobs)
   675             phases.retractboundary(repo, 2, expobs)
   663         finally:
   676         finally: