mercurial/tags.py
changeset 51599 b0aaffcb6fcf
parent 51598 2664cacd2457
equal deleted inserted replaced
51598:2664cacd2457 51599:b0aaffcb6fcf
    19     hex,
    19     hex,
    20     nullrev,
    20     nullrev,
    21     short,
    21     short,
    22 )
    22 )
    23 from .i18n import _
    23 from .i18n import _
       
    24 from .revlogutils.constants import ENTRY_NODE_ID
    24 from . import (
    25 from . import (
    25     encoding,
    26     encoding,
    26     error,
    27     error,
    27     match as matchmod,
    28     match as matchmod,
    28     scmutil,
    29     scmutil,
    29     util,
    30     util,
    30 )
    31 )
    31 from .utils import stringutil
    32 from .utils import stringutil
    32 
    33 
       
    34 
    33 # Tags computation can be expensive and caches exist to make it fast in
    35 # Tags computation can be expensive and caches exist to make it fast in
    34 # the common case.
    36 # the common case.
    35 #
    37 #
    36 # The "hgtagsfnodes1" cache file caches the .hgtags filenode values for
    38 # The "hgtagsfnodes1" cache file caches the .hgtags filenode values for
    37 # each revision in the repository. The file is effectively an array of
    39 # each revision in the repository. The file is effectively an array of
    81 
    83 
    82 
    84 
    83 def warm_cache(repo):
    85 def warm_cache(repo):
    84     """ensure the cache is properly filled"""
    86     """ensure the cache is properly filled"""
    85     unfi = repo.unfiltered()
    87     unfi = repo.unfiltered()
    86     _getfnodes(repo.ui, repo, revs=unfi.changelog.revs())
    88     fnodescache = hgtagsfnodescache(unfi)
       
    89     validated_fnodes = set()
       
    90     unknown_entries = set()
       
    91     flog = None
       
    92 
       
    93     entries = enumerate(repo.changelog.index)
       
    94     node_revs = ((e[ENTRY_NODE_ID], rev) for (rev, e) in entries)
       
    95 
       
    96     for node, rev in node_revs:
       
    97         fnode = fnodescache.getfnode(node=node, rev=rev)
       
    98         if fnode != repo.nullid:
       
    99             if fnode not in validated_fnodes:
       
   100                 if flog is None:
       
   101                     flog = repo.file(b'.hgtags')
       
   102                 if flog.hasnode(fnode):
       
   103                     validated_fnodes.add(fnode)
       
   104                 else:
       
   105                     unknown_entries.add(node)
       
   106 
       
   107     if unknown_entries:
       
   108         fnodescache.refresh_invalid_nodes(unknown_entries)
       
   109 
       
   110     fnodescache.write()
    87 
   111 
    88 
   112 
    89 def fnoderevs(ui, repo, revs):
   113 def fnoderevs(ui, repo, revs):
    90     """return the list of '.hgtags' fnodes used in a set revisions
   114     """return the list of '.hgtags' fnodes used in a set revisions
    91 
   115