mercurial/branchmap.py
changeset 51972 41b8892a2054
parent 51968 dd3ccda3abc8
child 51973 42a116f1cdc1
equal deleted inserted replaced
51971:76416b6e9d9b 51972:41b8892a2054
   908 
   908 
   909     def _write_heads(self, repo, fp) -> int:
   909     def _write_heads(self, repo, fp) -> int:
   910         """write list of heads to a file
   910         """write list of heads to a file
   911 
   911 
   912         Return the number of heads written."""
   912         Return the number of heads written."""
       
   913         to_node = repo.changelog.node
   913         nodecount = 0
   914         nodecount = 0
   914         topo_heads = None
   915         topo_heads = None
   915         if self._pure_topo_branch is None:
   916         if self._pure_topo_branch is None:
   916             topo_heads = set(self._get_topo_heads(repo))
   917             # we match using node because it is faster to built the set of node
   917         to_rev = repo.changelog.index.rev
   918             # than to resolve node → rev later.
       
   919             topo_heads = set(to_node(r) for r in self._get_topo_heads(repo))
   918         for label, nodes in sorted(self._entries.items()):
   920         for label, nodes in sorted(self._entries.items()):
   919             if label == self._pure_topo_branch:
   921             if label == self._pure_topo_branch:
   920                 # not need to write anything the header took care of that
   922                 # not need to write anything the header took care of that
   921                 continue
   923                 continue
   922             label = encoding.fromlocal(label)
   924             label = encoding.fromlocal(label)
   923             for node in nodes:
   925             for node in nodes:
   924                 if topo_heads is not None:
   926                 if topo_heads is not None:
   925                     rev = to_rev(node)
   927                     if node in topo_heads:
   926                     if rev in topo_heads:
       
   927                         continue
   928                         continue
   928                 if node in self._closednodes:
   929                 if node in self._closednodes:
   929                     state = b'c'
   930                     state = b'c'
   930                 else:
   931                 else:
   931                     state = b'o'
   932                     state = b'o'