mercurial/obsutil.py
changeset 34421 95759620d492
parent 34420 fa26f5891e68
child 34422 187bc224554a
equal deleted inserted replaced
34420:fa26f5891e68 34421:95759620d492
     4 #
     4 #
     5 # This software may be used and distributed according to the terms of the
     5 # This software may be used and distributed according to the terms of the
     6 # GNU General Public License version 2 or any later version.
     6 # GNU General Public License version 2 or any later version.
     7 
     7 
     8 from __future__ import absolute_import
     8 from __future__ import absolute_import
       
     9 
       
    10 import re
     9 
    11 
    10 from . import (
    12 from . import (
    11     phases,
    13     phases,
    12     util
    14     util
    13 )
    15 )
   307 
   309 
   308 # logic around storing and using effect flags
   310 # logic around storing and using effect flags
   309 EFFECTFLAGFIELD = "ef1"
   311 EFFECTFLAGFIELD = "ef1"
   310 
   312 
   311 DESCCHANGED = 1 << 0 # action changed the description
   313 DESCCHANGED = 1 << 0 # action changed the description
       
   314 METACHANGED = 1 << 1 # action change the meta
   312 PARENTCHANGED = 1 << 2 # action change the parent
   315 PARENTCHANGED = 1 << 2 # action change the parent
   313 USERCHANGED = 1 << 4 # the user changed
   316 USERCHANGED = 1 << 4 # the user changed
   314 DATECHANGED = 1 << 5 # the date changed
   317 DATECHANGED = 1 << 5 # the date changed
   315 BRANCHCHANGED = 1 << 6 # the branch changed
   318 BRANCHCHANGED = 1 << 6 # the branch changed
   316 
   319 
       
   320 METABLACKLIST = [
       
   321     re.compile('^branch$'),
       
   322     re.compile('^.*-source$'),
       
   323     re.compile('^.*_source$'),
       
   324     re.compile('^source$'),
       
   325 ]
       
   326 
       
   327 def metanotblacklisted(metaitem):
       
   328     """ Check that the key of a meta item (extrakey, extravalue) does not
       
   329     match at least one of the blacklist pattern
       
   330     """
       
   331     metakey = metaitem[0]
       
   332 
       
   333     return not any(pattern.match(metakey) for pattern in METABLACKLIST)
       
   334 
   317 def geteffectflag(relation):
   335 def geteffectflag(relation):
   318     """ From an obs-marker relation, compute what changed between the
   336     """ From an obs-marker relation, compute what changed between the
   319     predecessor and the successor.
   337     predecessor and the successor.
   320     """
   338     """
   321     effects = 0
   339     effects = 0
   340             effects |= BRANCHCHANGED
   358             effects |= BRANCHCHANGED
   341 
   359 
   342         # Check if at least one of the parent has changed
   360         # Check if at least one of the parent has changed
   343         if changectx.parents() != source.parents():
   361         if changectx.parents() != source.parents():
   344             effects |= PARENTCHANGED
   362             effects |= PARENTCHANGED
       
   363 
       
   364         # Check if other meta has changed
       
   365         changeextra = changectx.extra().items()
       
   366         ctxmeta = filter(metanotblacklisted, changeextra)
       
   367 
       
   368         sourceextra = source.extra().items()
       
   369         srcmeta = filter(metanotblacklisted, sourceextra)
       
   370 
       
   371         if ctxmeta != srcmeta:
       
   372             effects |= METACHANGED
   345 
   373 
   346     return effects
   374     return effects
   347 
   375 
   348 def getobsoleted(repo, tr):
   376 def getobsoleted(repo, tr):
   349     """return the set of pre-existing revisions obsoleted by a transaction"""
   377     """return the set of pre-existing revisions obsoleted by a transaction"""