EasyRepository SystemsPython 3

Repository Diff

Compare two repository snapshots and produce deterministic added, removed, and modified file changes.

30m2 sample tests4 hidden tests

Implement diff_repositories(old_files, new_files), a deterministic file-level diff between two repository snapshots.

Requirements

  • Inputs are dictionaries from path to content hash.
  • Return a list of (status, path) pairs.
  • Status must be "ADDED", "REMOVED", or "MODIFIED".
  • Unchanged files must not appear.
  • Output must be sorted by path, then status.
  • Treat renames as remove plus add.
  • Reject invalid paths with empty segments or ...

Example

python
1old = {"README.md": "a", "src/app.py": "1"} 2new = {"README.md": "a", "src/app.py": "2", "src/test.py": "3"} 3 4assert diff_repositories(old, new) == [ 5 ("MODIFIED", "src/app.py"), 6 ("ADDED", "src/test.py"), 7]

Constraints

  • Keep the implementation deterministic.
  • Use the provided content hashes directly.
  • Don't try to infer renames unless a follow-up asks for it.

Editor