Skip to content

Commit

Permalink
index: diff: support specifying start key (#444)
Browse files Browse the repository at this point in the history
  • Loading branch information
efiop authored Sep 27, 2023
1 parent 7a015de commit 0db221f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/dvc_data/index/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,19 +167,22 @@ def _diff(
meta_cmp_key: Optional[Callable[[Optional["Meta"]], Any]] = None,
shallow: Optional[bool] = False,
callback: Callback = DEFAULT_CALLBACK,
start: Optional["DataIndexKey"] = None,
):
old_root_items = {}
new_root_items = {}

start = start or ()

if old is not None:
try:
old_root_items[()] = old.info(())
old_root_items[start] = old.info(start)
except FileNotFoundError:
pass

if new is not None:
try:
new_root_items[()] = new.info(())
new_root_items[start] = new.info(start)
except FileNotFoundError:
pass

Expand Down Expand Up @@ -290,6 +293,7 @@ def diff(
meta_cmp_key: Optional[Callable[[Optional["Meta"]], Any]] = None,
shallow: Optional[bool] = False,
callback: Callback = DEFAULT_CALLBACK,
start: Optional["DataIndexKey"] = None,
):
changes = _diff(
old,
Expand All @@ -301,6 +305,7 @@ def diff(
meta_cmp_key=meta_cmp_key,
shallow=shallow,
callback=callback,
start=start,
)

if with_renames and old is not None and new is not None:
Expand Down

0 comments on commit 0db221f

Please sign in to comment.