hgext/obsolete.py
branchstable
changeset 354 bd26eb9714fb
parent 351 4ecbaec1d664
child 356 56d4c6207ef9
equal deleted inserted replaced
352:de3edd3856c3 354:bd26eb9714fb
   150         return False
   150         return False
   151     return ctx.rev() in ctx._repo._latecomerset
   151     return ctx.rev() in ctx._repo._latecomerset
   152 
   152 
   153 context.changectx.latecomer = latecomer
   153 context.changectx.latecomer = latecomer
   154 
   154 
       
   155 def conflicting(ctx):
       
   156     """is the changeset conflicting (Try to succeed to public change)"""
       
   157     if ctx.node() is None:
       
   158         return False
       
   159     return ctx.rev() in ctx._repo._conflictingset
       
   160 
       
   161 context.changectx.conflicting = conflicting
       
   162 
   155 
   163 
   156 ### revset
   164 ### revset
   157 #############################
   165 #############################
   158 
   166 
   159 def revsethidden(repo, subset, x):
   167 def revsethidden(repo, subset, x):
   190 
   198 
   191 def revsetlatecomer(repo, subset, x):
   199 def revsetlatecomer(repo, subset, x):
   192     """latecomer, Try to succeed to public change"""
   200     """latecomer, Try to succeed to public change"""
   193     args = revset.getargs(x, 0, 0, 'latecomer takes no arguments')
   201     args = revset.getargs(x, 0, 0, 'latecomer takes no arguments')
   194     return [r for r in subset if r in repo._latecomerset]
   202     return [r for r in subset if r in repo._latecomerset]
       
   203 
       
   204 def revsetconflicting(repo, subset, x):
       
   205     """conflicting, Try to succeed to public change"""
       
   206     args = revset.getargs(x, 0, 0, 'conflicting takes no arguments')
       
   207     return [r for r in subset if r in repo._conflictingset]
   195 
   208 
   196 def _precursors(repo, s):
   209 def _precursors(repo, s):
   197     """Precursor of a changeset"""
   210     """Precursor of a changeset"""
   198     cs = set()
   211     cs = set()
   199     nm = repo.changelog.nodemap
   212     nm = repo.changelog.nodemap
   389     revset.symbols["obsolete"] = revsetobsolete
   402     revset.symbols["obsolete"] = revsetobsolete
   390     revset.symbols["unstable"] = revsetunstable
   403     revset.symbols["unstable"] = revsetunstable
   391     revset.symbols["suspended"] = revsetsuspended
   404     revset.symbols["suspended"] = revsetsuspended
   392     revset.symbols["extinct"] = revsetextinct
   405     revset.symbols["extinct"] = revsetextinct
   393     revset.symbols["latecomer"] = revsetlatecomer
   406     revset.symbols["latecomer"] = revsetlatecomer
       
   407     revset.symbols["conflicting"] = revsetconflicting
   394     revset.symbols["obsparents"] = revsetprecursors  # DEPR
   408     revset.symbols["obsparents"] = revsetprecursors  # DEPR
   395     revset.symbols["precursors"] = revsetprecursors
   409     revset.symbols["precursors"] = revsetprecursors
   396     revset.symbols["obsancestors"] = revsetallprecursors  # DEPR
   410     revset.symbols["obsancestors"] = revsetallprecursors  # DEPR
   397     revset.symbols["allprecursors"] = revsetallprecursors  # bad name
   411     revset.symbols["allprecursors"] = revsetallprecursors  # bad name
   398     revset.symbols["successors"] = revsetsuccessors
   412     revset.symbols["successors"] = revsetsuccessors
   480         if ctx.obsolete():
   494         if ctx.obsolete():
   481             raise util.Abort(_("Trying to push obsolete changeset: %s!") % ctx,
   495             raise util.Abort(_("Trying to push obsolete changeset: %s!") % ctx,
   482                              hint=hint)
   496                              hint=hint)
   483         if ctx.latecomer():
   497         if ctx.latecomer():
   484             raise util.Abort(_("Trying to push latecomer changeset: %s!") % ctx,
   498             raise util.Abort(_("Trying to push latecomer changeset: %s!") % ctx,
       
   499                              hint=hint)
       
   500         if ctx.conflicting():
       
   501             raise util.Abort(_("Trying to push conflicting changeset: %s!") % ctx,
   485                              hint=hint)
   502                              hint=hint)
   486     ### patch remote branch map
   503     ### patch remote branch map
   487     # do not read it this burn eyes
   504     # do not read it this burn eyes
   488     try:
   505     try:
   489         if 'oldbranchmap' not in vars(remote):
   506         if 'oldbranchmap' not in vars(remote):
  1029         def _latecomerset(self):
  1046         def _latecomerset(self):
  1030             """the set of rev trying to obsolete public revision"""
  1047             """the set of rev trying to obsolete public revision"""
  1031             query = 'allsuccessors(public()) - obsolete() - public()'
  1048             query = 'allsuccessors(public()) - obsolete() - public()'
  1032             return set(self.revs(query))
  1049             return set(self.revs(query))
  1033 
  1050 
       
  1051         @util.propertycache
       
  1052         def _conflictingset(self):
       
  1053             """the set of rev trying to obsolete public revision"""
       
  1054             conflicting = set()
       
  1055             obsstore = self.obsstore
       
  1056             newermap = {}
       
  1057             for ctx in self.set('(not public()) - obsolete()'):
       
  1058                 prec = obsstore.successors.get(ctx.node(), ())
       
  1059                 toprocess = set(prec)
       
  1060                 while toprocess:
       
  1061                     prec = toprocess.pop()[0]
       
  1062                     if prec not in newermap:
       
  1063                         newermap[prec] = newerversion(self, prec)
       
  1064                     newer = [n for n in newermap[prec] if n] # filter kill
       
  1065                     if len(newer) > 1:
       
  1066                         conflicting.add(ctx.rev())
       
  1067                         break
       
  1068                 toprocess.update(obsstore.successors.get(prec, ()))
       
  1069             return conflicting
       
  1070 
  1034         def _clearobsoletecache(self):
  1071         def _clearobsoletecache(self):
  1035             if '_obsoleteset' in vars(self):
  1072             if '_obsoleteset' in vars(self):
  1036                 del self._obsoleteset
  1073                 del self._obsoleteset
  1037             self._clearunstablecache()
  1074             self._clearunstablecache()
  1038 
  1075 
  1047                 del self._suspendedset
  1084                 del self._suspendedset
  1048             if '_extinctset' in vars(self):
  1085             if '_extinctset' in vars(self):
  1049                 del self._extinctset
  1086                 del self._extinctset
  1050             if '_latecomerset' in vars(self):
  1087             if '_latecomerset' in vars(self):
  1051                 del self._latecomerset
  1088                 del self._latecomerset
       
  1089             if '_conflictingset' in vars(self):
       
  1090                 del self._conflictingset
  1052 
  1091 
  1053         def addobsolete(self, sub, obj):
  1092         def addobsolete(self, sub, obj):
  1054             """Add a relation marking that node <sub> is a new version of <obj>"""
  1093             """Add a relation marking that node <sub> is a new version of <obj>"""
  1055             assert sub != obj
  1094             assert sub != obj
  1056             if not repo[obj].phase():
  1095             if not repo[obj].phase():