hgext/obsolete.py
changeset 382 58fdb2180064
parent 381 3a161a89d65d
child 383 57bccc6452e9
equal deleted inserted replaced
381:3a161a89d65d 382:58fdb2180064
   446     # do not push instability
   446     # do not push instability
   447     for h in outgoing.missingheads:
   447     for h in outgoing.missingheads:
   448         # checking heads only is enought because any thing base on obsolete
   448         # checking heads only is enought because any thing base on obsolete
   449         # changeset is either obsolete or unstable.
   449         # changeset is either obsolete or unstable.
   450         ctx =  repo[h]
   450         ctx =  repo[h]
   451         if ctx.unstable():
       
   452             raise util.Abort(_("push includes an unstable changeset: %s!")
       
   453                              % ctx)
       
   454         if ctx.obsolete():
       
   455             raise util.Abort(_("push includes an  obsolete changeset: %s!")
       
   456                              % ctx)
       
   457         if ctx.latecomer():
   451         if ctx.latecomer():
   458             raise util.Abort(_("push includes an latecomer changeset: %s!")
   452             raise util.Abort(_("push includes an latecomer changeset: %s!")
   459                              % ctx)
   453                              % ctx)
   460         if ctx.conflicting():
   454         if ctx.conflicting():
   461             raise util.Abort(_("push includes conflicting changeset: %s!")
   455             raise util.Abort(_("push includes conflicting changeset: %s!")
   462                              % ctx)
   456                              % ctx)
   463     ### patch remote branch map
   457     return orig(repo, remote, outgoing, *args, **kwargs)
   464     # do not read it this burn eyes
       
   465     try:
       
   466         if 'oldbranchmap' not in vars(remote):
       
   467             remote.oldbranchmap = remote.branchmap
       
   468             def branchmap():
       
   469                 newbm = {}
       
   470                 oldbm = None
       
   471                 if (util.safehasattr(discovery, 'visiblebranchmap')
       
   472                     and not util.safehasattr(remote, 'ignorevisiblebranchmap')
       
   473                    ):
       
   474                     remote.ignorevisiblebranchmap = False
       
   475                     remote.branchmap = remote.oldbranchmap
       
   476                     oldbm = phases.visiblebranchmap(remote)
       
   477                     remote.branchmap = remote.newbranchmap
       
   478                     remote.ignorevisiblebranchmap = True
       
   479                 if oldbm is None:
       
   480                     oldbm = remote.oldbranchmap()
       
   481                 for branch, nodes in oldbm.iteritems():
       
   482                     nodes = list(nodes)
       
   483                     new = set()
       
   484                     while nodes:
       
   485                         n = nodes.pop()
       
   486                         if n in repo.obsstore.precursors:
       
   487                             markers = repo.obsstore.precursors[n]
       
   488                             for mark in markers:
       
   489                                 for newernode in mark[1]:
       
   490                                     if newernode is not None:
       
   491                                         nodes.append(newernode)
       
   492                         else:
       
   493                             new.add(n)
       
   494                     if new:
       
   495                         newbm[branch] = list(new)
       
   496                 return newbm
       
   497             remote.ignorevisiblebranchmap = True
       
   498             remote.branchmap = branchmap
       
   499             remote.newbranchmap = branchmap
       
   500         return orig(repo, remote, outgoing, *args, **kwargs)
       
   501     finally:
       
   502         remote.__dict__.pop('branchmap', None) # restore class one
       
   503         remote.__dict__.pop('oldbranchmap', None)
       
   504         remote.__dict__.pop('newbranchmap', None)
       
   505         remote.__dict__.pop('ignorevisiblebranchmap', None)
       
   506 
       
   507 # eye are still burning
       
   508 def wrapvisiblebranchmap(orig, repo):
       
   509     ignore = getattr(repo, 'ignorevisiblebranchmap', None)
       
   510     if ignore is None:
       
   511         return orig(repo)
       
   512     elif ignore:
       
   513         return repo.branchmap()
       
   514     else:
       
   515         return None # break recursion
       
   516 
   458 
   517 def wrapclearcache(orig, repo, *args, **kwargs):
   459 def wrapclearcache(orig, repo, *args, **kwargs):
   518     try:
   460     try:
   519         return orig(repo, *args, **kwargs)
   461         return orig(repo, *args, **kwargs)
   520     finally:
   462     finally:
   709     if util.safehasattr(cmdutil, 'amend'):
   651     if util.safehasattr(cmdutil, 'amend'):
   710         extensions.wrapfunction(cmdutil, 'amend', wrapcmdutilamend)
   652         extensions.wrapfunction(cmdutil, 'amend', wrapcmdutilamend)
   711     extensions.wrapfunction(discovery, 'checkheads', wrapcheckheads)
   653     extensions.wrapfunction(discovery, 'checkheads', wrapcheckheads)
   712     extensions.wrapfunction(discovery, 'visibleheads', noextinctsvisibleheads)
   654     extensions.wrapfunction(discovery, 'visibleheads', noextinctsvisibleheads)
   713     extensions.wrapfunction(phases, 'advanceboundary', wrapclearcache)
   655     extensions.wrapfunction(phases, 'advanceboundary', wrapclearcache)
   714     if util.safehasattr(discovery, 'visiblebranchmap'):
       
   715         extensions.wrapfunction(discovery, 'visiblebranchmap', wrapvisiblebranchmap)
       
   716 
   656 
   717 ### serialisation
   657 ### serialisation
   718 #############################
   658 #############################
   719 
   659 
   720 def _obsserialise(obssubrels, flike):
   660 def _obsserialise(obssubrels, flike):