MCPcopy Index your code
hub / github.com/Codeplain-ai/codeplain / _classify_changes

Function _classify_changes

change_detection.py:132–170  ·  view source on GitHub ↗
(
    old_frs: list[str], new_frs: list[str]
)

Source from the content-addressed store, hash-verified

130
131
132def _classify_changes(
133 old_frs: list[str], new_frs: list[str]
134) -> tuple[list[tuple[int, int]], list[int], list[int], list[int]]:
135 matched_old: set[int] = set()
136 matched_new: set[int] = set()
137
138 for i in range(min(len(old_frs), len(new_frs))):
139 if old_frs[i] == new_frs[i]:
140 matched_old.add(i)
141 matched_new.add(i)
142
143 content_matches: list[tuple[int, int]] = []
144 for old_idx in range(len(old_frs)):
145 if old_idx in matched_old:
146 continue
147 for new_idx in range(len(new_frs)):
148 if new_idx in matched_new:
149 continue
150 if old_frs[old_idx] == new_frs[new_idx]:
151 content_matches.append((old_idx, new_idx))
152 matched_old.add(old_idx)
153 matched_new.add(new_idx)
154 break
155
156 moves: list[tuple[int, int]] = []
157 if content_matches and _has_relative_order_change(content_matches):
158 moves = content_matches
159
160 edits: list[int] = []
161 for i in range(min(len(old_frs), len(new_frs))):
162 if i not in matched_old and i not in matched_new:
163 edits.append(i)
164 matched_old.add(i)
165 matched_new.add(i)
166
167 removed = [i for i in range(len(old_frs)) if i not in matched_old]
168 added = [i for i in range(len(new_frs)) if i not in matched_new]
169
170 return moves, edits, removed, added
171
172
173def _has_relative_order_change(matches: list[tuple[int, int]]) -> bool:

Callers 1

_detect_module_changesFunction · 0.85

Calls 1

Tested by

no test coverage detected