hgext3rd/evolve/obshistory.py
changeset 5328 a81631766575
parent 5327 b1a564cb18d0
child 5329 0dc4c16506fc
equal deleted inserted replaced
5327:b1a564cb18d0 5328:a81631766575
   134     b"dates": TEMPLATE_DATES,
   134     b"dates": TEMPLATE_DATES,
   135     b"notes": TEMPLATE_NOTES,
   135     b"notes": TEMPLATE_NOTES,
   136     b"patch": TEMPLATE_PATCH,
   136     b"patch": TEMPLATE_PATCH,
   137 }
   137 }
   138 
   138 
       
   139 def groupbyfoldid(predsets):
       
   140     """ Group nodes and related obsmarkers by fold-id metadata.
       
   141     """
       
   142     groups = {}
       
   143     for (nodes, markers) in predsets:
       
   144         grouped = False
       
   145         for marker in markers:
       
   146             metadata = dict(marker[3])
       
   147             foldid = metadata.get(b'fold-id')
       
   148             if foldid is not None:
       
   149                 groups.setdefault(foldid, []).append((nodes, markers))
       
   150                 grouped = True
       
   151 
       
   152         if not grouped:
       
   153             yield (nodes, markers)
       
   154 
       
   155     for foldid in sorted(groups):
       
   156         groupnodes = set()
       
   157         groupmarkers = set()
       
   158         for (nodes, markers) in groups[foldid]:
       
   159             groupnodes.update(nodes)
       
   160             groupmarkers.update(markers)
       
   161         yield (tuple(sorted(groupnodes)), tuple(sorted(groupmarkers)))
       
   162 
   139 def _nodesandmarkers(repo, ctx, filternonlocal):
   163 def _nodesandmarkers(repo, ctx, filternonlocal):
   140     if filternonlocal:
   164     if filternonlocal:
   141         r = obsutil.successorsandmarkers(repo, ctx)
   165         r = obsutil.successorsandmarkers(repo, ctx)
   142         if r is None:
   166         if r is None:
   143             r = []
   167             r = []