mercurial/branchmap.py
changeset 20032 175c6fd8cacc
parent 19839 a32ef044b99a
child 20181 b9515fb9e72a
equal deleted inserted replaced
20031:6c1adf2067bb 20032:175c6fd8cacc
     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 node import bin, hex, nullid, nullrev
     8 from node import bin, hex, nullid, nullrev
     9 import encoding
     9 import encoding
    10 import util, repoview
    10 import util
    11 
    11 
    12 def _filename(repo):
    12 def _filename(repo):
    13     """name of a branchcache file for a given repo or repoview"""
    13     """name of a branchcache file for a given repo or repoview"""
    14     filename = "cache/branchheads"
    14     filename = "cache/branchheads"
    15     if repo.filtername:
    15     if repo.filtername:
    56         partial = None
    56         partial = None
    57     return partial
    57     return partial
    58 
    58 
    59 
    59 
    60 
    60 
       
    61 ### Nearest subset relation
       
    62 # Nearest subset of filter X is a filter Y so that:
       
    63 # * Y is included in X,
       
    64 # * X - Y is as small as possible.
       
    65 # This create and ordering used for branchmap purpose.
       
    66 # the ordering may be partial
       
    67 subsettable = {None: 'visible',
       
    68                'visible': 'served',
       
    69                'served': 'immutable',
       
    70                'immutable': 'base'}
       
    71 
    61 def updatecache(repo):
    72 def updatecache(repo):
    62     cl = repo.changelog
    73     cl = repo.changelog
    63     filtername = repo.filtername
    74     filtername = repo.filtername
    64     partial = repo._branchcaches.get(filtername)
    75     partial = repo._branchcaches.get(filtername)
    65 
    76 
    66     revs = []
    77     revs = []
    67     if partial is None or not partial.validfor(repo):
    78     if partial is None or not partial.validfor(repo):
    68         partial = read(repo)
    79         partial = read(repo)
    69         if partial is None:
    80         if partial is None:
    70             subsetname = repoview.subsettable.get(filtername)
    81             subsetname = subsettable.get(filtername)
    71             if subsetname is None:
    82             if subsetname is None:
    72                 partial = branchcache()
    83                 partial = branchcache()
    73             else:
    84             else:
    74                 subset = repo.filtered(subsetname)
    85                 subset = repo.filtered(subsetname)
    75                 partial = subset.branchmap().copy()
    86                 partial = subset.branchmap().copy()