mercurial/branchmap.py
changeset 51537 4a8bb136ee77
parent 51536 718f28ea3af4
equal deleted inserted replaced
51536:718f28ea3af4 51537:4a8bb136ee77
    67             bcache._filtername,
    67             bcache._filtername,
    68             repo.filtername,
    68             repo.filtername,
    69         )
    69         )
    70         return bcache
    70         return bcache
    71 
    71 
    72     def update_disk(self, repo):
    72     def update_disk(self, repo, detect_pure_topo=False):
    73         """ensure and up-to-date cache is (or will be) written on disk
    73         """ensure and up-to-date cache is (or will be) written on disk
    74 
    74 
    75         The cache for this repository view is updated  if needed and written on
    75         The cache for this repository view is updated  if needed and written on
    76         disk.
    76         disk.
    77 
    77 
    85         bcache = self._per_filter[repo.filtername]
    85         bcache = self._per_filter[repo.filtername]
    86         assert bcache._filtername == repo.filtername, (
    86         assert bcache._filtername == repo.filtername, (
    87             bcache._filtername,
    87             bcache._filtername,
    88             repo.filtername,
    88             repo.filtername,
    89         )
    89         )
       
    90         if detect_pure_topo:
       
    91             bcache._detect_pure_topo(repo)
    90         tr = repo.currenttransaction()
    92         tr = repo.currenttransaction()
    91         if getattr(tr, 'finalized', True):
    93         if getattr(tr, 'finalized', True):
    92             bcache.sync_disk(repo)
    94             bcache.sync_disk(repo)
    93 
    95 
    94     def updatecache(self, repo):
    96     def updatecache(self, repo):
   486         raise NotImplementedError
   488         raise NotImplementedError
   487 
   489 
   488     def _ensure_populated(self, repo):
   490     def _ensure_populated(self, repo):
   489         """make sure any lazily loaded values are fully populated"""
   491         """make sure any lazily loaded values are fully populated"""
   490 
   492 
       
   493     def _detect_pure_topo(self, repo) -> None:
       
   494         pass
       
   495 
   491     def validfor(self, repo):
   496     def validfor(self, repo):
   492         """check that cache contents are valid for (a subset of) this repo
   497         """check that cache contents are valid for (a subset of) this repo
   493 
   498 
   494         - False when the order of changesets changed or if we detect a strip.
   499         - False when the order of changesets changed or if we detect a strip.
   495         - True when cache is up-to-date for the current repo or its subset."""
   500         - True when cache is up-to-date for the current repo or its subset."""
  1053             topo_heads = self._get_topo_heads(repo)
  1058             topo_heads = self._get_topo_heads(repo)
  1054             heads = [to_node(r) for r in topo_heads]
  1059             heads = [to_node(r) for r in topo_heads]
  1055             self._entries[self._pure_topo_branch] = heads
  1060             self._entries[self._pure_topo_branch] = heads
  1056             self._needs_populate = False
  1061             self._needs_populate = False
  1057 
  1062 
       
  1063     def _detect_pure_topo(self, repo) -> None:
       
  1064         if self._pure_topo_branch is not None:
       
  1065             # we are pure topological already
       
  1066             return
       
  1067         to_node = repo.changelog.node
       
  1068         topo_heads = [to_node(r) for r in self._get_topo_heads(repo)]
       
  1069         if any(n in self._closednodes for n in topo_heads):
       
  1070             return
       
  1071         for branch, heads in self._entries.items():
       
  1072             if heads == topo_heads:
       
  1073                 self._pure_topo_branch = branch
       
  1074                 break
       
  1075 
  1058 
  1076 
  1059 class remotebranchcache(_BaseBranchCache):
  1077 class remotebranchcache(_BaseBranchCache):
  1060     """Branchmap info for a remote connection, should not write locally"""
  1078     """Branchmap info for a remote connection, should not write locally"""
  1061 
  1079 
  1062     def __init__(
  1080     def __init__(