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 = [] |