1093 heads = [c.node() for c in repo.set(revset, headsbyphase[phase], phase)] |
1093 heads = [c.node() for c in repo.set(revset, headsbyphase[phase], phase)] |
1094 if heads: |
1094 if heads: |
1095 advanceboundary(repo, trgetter(), phase, heads) |
1095 advanceboundary(repo, trgetter(), phase, heads) |
1096 |
1096 |
1097 |
1097 |
1098 def analyzeremotephases(repo, subset, roots): |
1098 def analyze_remote_phases( |
|
1099 repo, |
|
1100 subset: Collection[int], |
|
1101 roots: Dict[bytes, bytes], |
|
1102 ) -> Tuple[Collection[int], Collection[int]]: |
1099 """Compute phases heads and root in a subset of node from root dict |
1103 """Compute phases heads and root in a subset of node from root dict |
1100 |
1104 |
1101 * subset is heads of the subset |
1105 * subset is heads of the subset |
1102 * roots is {<nodeid> => phase} mapping. key and value are string. |
1106 * roots is {<nodeid> => phase} mapping. key and value are string. |
1103 |
1107 |
1105 """ |
1109 """ |
1106 repo = repo.unfiltered() |
1110 repo = repo.unfiltered() |
1107 # build list from dictionary |
1111 # build list from dictionary |
1108 draft_roots = [] |
1112 draft_roots = [] |
1109 to_rev = repo.changelog.index.get_rev |
1113 to_rev = repo.changelog.index.get_rev |
1110 to_node = repo.changelog.node |
|
1111 for nhex, phase in roots.items(): |
1114 for nhex, phase in roots.items(): |
1112 if nhex == b'publishing': # ignore data related to publish option |
1115 if nhex == b'publishing': # ignore data related to publish option |
1113 continue |
1116 continue |
1114 node = bin(nhex) |
1117 node = bin(nhex) |
1115 phase = int(phase) |
1118 phase = int(phase) |
1123 draft_roots.append(rev) |
1126 draft_roots.append(rev) |
1124 else: |
1127 else: |
1125 msg = _(b'ignoring unexpected root from remote: %i %s\n') |
1128 msg = _(b'ignoring unexpected root from remote: %i %s\n') |
1126 repo.ui.warn(msg % (phase, nhex)) |
1129 repo.ui.warn(msg % (phase, nhex)) |
1127 # compute heads |
1130 # compute heads |
1128 subset_revs = [to_rev(n) for n in subset] |
1131 public_heads = new_heads(repo, subset, draft_roots) |
1129 public_heads = new_heads(repo, subset_revs, draft_roots) |
1132 return public_heads, draft_roots |
1130 draft_nodes = [to_node(r) for r in draft_roots] |
|
1131 public_nodes = [to_node(r) for r in public_heads] |
|
1132 return public_nodes, draft_nodes |
|
1133 |
1133 |
1134 |
1134 |
1135 class remotephasessummary: |
1135 class remotephasessummary: |
1136 """summarize phase information on the remote side |
1136 """summarize phase information on the remote side |
1137 |
1137 |
1141 :draftroots: list of remote draft phase root (nodes) |
1141 :draftroots: list of remote draft phase root (nodes) |
1142 """ |
1142 """ |
1143 |
1143 |
1144 def __init__(self, repo, remotesubset, remoteroots): |
1144 def __init__(self, repo, remotesubset, remoteroots): |
1145 unfi = repo.unfiltered() |
1145 unfi = repo.unfiltered() |
|
1146 to_rev = unfi.changelog.index.rev |
|
1147 to_node = unfi.changelog.node |
1146 self._allremoteroots = remoteroots |
1148 self._allremoteroots = remoteroots |
1147 |
1149 |
1148 self.publishing = remoteroots.get(b'publishing', False) |
1150 self.publishing = remoteroots.get(b'publishing', False) |
1149 |
1151 |
1150 ana = analyzeremotephases(repo, remotesubset, remoteroots) |
1152 remote_subset = [to_rev(n) for n in remotesubset] |
1151 self.publicheads, self.draftroots = ana |
1153 heads, roots = analyze_remote_phases(repo, remote_subset, remoteroots) |
|
1154 self.publicheads = [to_node(r) for r in heads] |
|
1155 self.draftroots = [to_node(r) for r in roots] |
1152 # Get the list of all "heads" revs draft on remote |
1156 # Get the list of all "heads" revs draft on remote |
1153 dheads = unfi.set(b'heads(%ln::%ln)', self.draftroots, remotesubset) |
1157 dheads = unfi.set(b'heads(%ld::%ld)', roots, remote_subset) |
1154 self.draftheads = [c.node() for c in dheads] |
1158 self.draftheads = [c.node() for c in dheads] |
1155 |
1159 |
1156 |
1160 |
1157 def new_heads( |
1161 def new_heads( |
1158 repo, |
1162 repo, |