MCPcopy Create free account
hub / github.com/HKUDS/OpenSpace / _unified_diff

Method _unified_diff

openspace/cloud/client.py:538–554  ·  view source on GitHub ↗

Compute combined unified diff between two file snapshots.

(old_files: Dict[str, str], new_files: Dict[str, str])

Source from the content-addressed store, hash-verified

536
537 @staticmethod
538 def _unified_diff(old_files: Dict[str, str], new_files: Dict[str, str]) -> Optional[str]:
539 """Compute combined unified diff between two file snapshots."""
540 all_names = sorted(set(old_files) | set(new_files))
541 parts: List[str] = []
542 for fname in all_names:
543 old = old_files.get(fname, "")
544 new = new_files.get(fname, "")
545 d = "".join(difflib.unified_diff(
546 old.splitlines(keepends=True),
547 new.splitlines(keepends=True),
548 fromfile=f"a/{fname}",
549 tofile=f"b/{fname}",
550 n=3,
551 ))
552 if d:
553 parts.append(d)
554 return "\n".join(parts) if parts else None

Callers 1

_compute_content_diffMethod · 0.95

Calls 1

getMethod · 0.80

Tested by

no test coverage detected